Several Issues with 5.6.0f3

Issue #74 resolved
Former user created an issue

I have some issues with Unity 5.6.0f3.

Last Screenshot on opening Unity Project.

We have basically two classes.

Test inherits from SerializedMonobehaviour

World is a pure c# class. And we want that data to be displayed in Unity. Our idea was to use to a World instance (which is actually a Singleton Instance) from the SerializedMonobehaviour (as seen on the Screenshots).

Sometimes it works (see third Screenshot), but sometimes the World object is not displayed

I don't know if it is related to Unity 5.6 (Asset Store Submit was 5.3).

Comments (4)

  1. Lucas Taniolo

    I'm having this issue too, but here it will not work at all, same errors as above.

    I tried to serialize a list of interfaces and made some tests with simple variables like float and string as well.

  2. Bjarke Elias

    Thanks for the good info :)

    The error message you are showing is solved in the version. If you send us an email with your invoice I'll send you the latest version containing the fix.

    Also a fair warning about your singleton that might be the cause of some of your issues. The singleton does not reference the instance serialized by, so you will in some cases end up with two different instances of World.

    If you want the singleton to not be a serialized instance I would suggest not Serializing it in your Test.cs class. You can show a static variable like this:

    public World World 
          get { return World.Get();  }
          set { } // properties without a setter will become read-only so in this case, this is a small hack to make it editable.

    Another way is to save the World as a serialized obejct, and referencing that from your monobehaviour. The World singleton would then create or load itself from the resources folder when asked for. We have a great singleton in the Odin for this sort of thing which you could give a try:

    public class Test : MonoBehaviour //
         // If you want to show an editor for the singleton inline you can do the same trick: 
        [ShowInInspector, InlineEditor]
        public World World 
            get { return World.Instance;  }
            set { }
    [SirenixGlobalConfig("Resources/Singletons")] // The path for the singleton if you want it to be serialized.
    public class World : GlobalConfig<World>
  3. Tor Esa Vestergaard

    To add to the first example above, you could also write the following and achieve largely the same result:

    [NonSerialized, ShowInInspector]
    public World world = World.Get();
  4. Log in to comment