Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Solved] EditorGUILayout.ObjectField problem

Discussion in 'Immediate Mode GUI (IMGUI)' started by vitaliano-neto, Dec 3, 2009.

  1. vitaliano-neto

    vitaliano-neto

    Joined:
    Oct 19, 2009
    Posts:
    20
    The field apears on InspectorGUI and the drag'n'drop seems to work, but the value of the field don't change.

    The code:
    Code (csharp):
    1. navNodes[i] = EditorGUILayout.ObjectField ("NavmeshNode", navNodes[i], typeof(NavmeshNode)) as NavmeshNode;
    NavmeshNode extends ScriptableObject and it has a [System.Serializable] tag on top.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    When you say the value doesn't change, do you mean it always returns null or that you can set it once and then it keeps that value or... ?
     
  3. vitaliano-neto

    vitaliano-neto

    Joined:
    Oct 19, 2009
    Posts:
    20
    Well, I think it aways returns null, because the value doesn't change neither with drag'n'drop or with combo-box.
     
  4. vitaliano-neto

    vitaliano-neto

    Joined:
    Oct 19, 2009
    Posts:
    20
    I found the problem.
    I was setting the variable to a local var. :oops: