Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

struct MyStruct -- not persistent

Discussion in 'Immediate Mode GUI (IMGUI)' started by RobNotBob, Mar 18, 2008.

  1. RobNotBob

    RobNotBob

    Joined:
    Feb 20, 2008
    Posts:
    10
    struct MyStruct
    {
    blah
    }

    class MyData
    {
    MyStruct mS;
    Vector3 vec;
    }

    [CustomEditor (typeof(MyData))]
    public class MyEditor : Editor
    {
    //modify MyData
    }

    When I close down Unity and reopen, 'vec' persists but 'mS' is blown away! Any ideas why this might happen?

    Thanks.
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    You need to make MyStruct into a class and attach the [System.Serializable] attribute to it.