Answer the question
In order to leave comments, you need to log in
What is the best way to get to a component that is common to several classes?
ItemInfo is used in several classes and carries general information about objects.
Can this code be made more concise?
public void SetItemInfo(ItemInfo info)
{
if (GetComponent<InstanceWeapon>())
{
GetComponent<InstanceWeapon>().itemInfo = info;
}
if (GetComponent<InstanceLook>())
{
GetComponent<InstanceLook>().itemInfo = info;
}
if (GetComponent<InstanceSupport>())
{
GetComponent<InstanceSupport>().itemInfo = info;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question