Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

[ReorderableList] Cant change Variables inner Foldout tab

Discussion in 'Extensions & OnGUI' 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:
    640
    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:
    93
    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. }