Hello.
I am trying to use EditorGuiLayout.PopUp, but the string array is in another component attached to the same object.
I am using a PropertyAttribute and a CustomPropertyDrawer. I have to access the monobehaviour inside the drawer.
public class ClassA : MonoBehaviour
{
public List<Foo> foos = new List<Foo>();
[Serializable]
private class Foo
{
[MyAttribute]
public string field;
{
// custom property attribute
public class MyAttribute : PropertyAttribute
{
}
[CustomPropertyDrawer(typeof(MyAttribute))]
public class MyAttributeDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
// how can I get the instance of classA ????
ClassA a;
// use getComponent
string[] names = a.GetComponent<MyOtherComponent>().getNames();
// draw
Editor.PopUp( ... , names)
}
}
}
How can I access the instance of ClassA ?
Note: I have simplified the code to make it easier to read. Everything else works fine.