Search Unity

[ReorderableList] Cant change Variables inner Foldout tab

Discussion in 'Immediate Mode GUI (IMGUI)' started by Pandalawl, Sep 3, 2018.

  1. Pandalawl

    Pandalawl

    Joined:
    Jan 27, 2017
    Posts:
    8
    Hello,

    Im tryin to create a ReorderableList each entry is a ScriptableObject,
    and I wanna create a Foldout tab to hide/show the variables from the ScriptableObject.
    Wich works fine but i cant change the Varaibles anymore....i guess it has something to do with
    elementHeightCallback / elementHeight but idk...p

    Thats my Editor Code so far https://pastebin.com/0pnKdCxK
    thats how it looks
    https://imgur.com/a/ZBbAJ9Z

    pls some Help ;_;
     
    Last edited: Sep 3, 2018
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    I believe you need to call target.ApplyModifiedProperties()

    I would also cache these serializedObjects to a dictionary.
    Rebuild the dictionary on enable and when an object changes
     
  3. Pandalawl

    Pandalawl

    Joined:
    Jan 27, 2017
    Posts:
    8
    So I changed my Script a bit
    https://hastebin.com/ebuhiliqar.cs

    and im using target.ApplyModifiedProperties() at 2 positions
    but it dont change the problem.

    Good idea to cache them to a dictionary, will try that. Thanks
     
  4. PsyKaw

    PsyKaw

    Joined:
    Aug 16, 2012
    Posts:
    102
    In you code, add this when you draw ScriptableObject properties:

    Code (CSharp):
    1. if (item.isExpanded)
    2. {
    3.     SerializedObject target = new SerializedObject(item.objectReferenceValue);
    4.     target.Update();
    5.     // Your code here
    6.     target.ApplyModifiedProperties();
    7. }