jacobdufault / fullinspector

Full Inspector supercharges Unity's inspector
MIT License
111 stars 27 forks source link

SharedInstance<> not working #179

Closed Radghiv closed 7 years ago

Radghiv commented 7 years ago

An exception is thrown when deserialising a SharedInstance in version 2.6.3 on Unity 5.4.1f1. The same problem occurs even in the latest build from the github repository.

Following the guide here is enough to reproduce the issue: http://jacobdufault.github.io/fullinspector/guide/#docs/workflow_shared_instance

Shared Instances in version 2.6.2 on Unity 5.0.2 work perfectly.

Here is the exception:

ToString is not allowed to be called during serialization, call it from Awake or Start instead. Called from MonoBehaviour 'MyDemoBehavior1' on game object 'GameObject'.
See "Script Serialization" page in the Unity Manual for further details.
System.String:Concat(Object[])
FullInspector.InspectedProperty:Write(Object, Object) (at Assets/FullInspector2/Core/Utility/InspectedProperty.cs:139)
FullInspector.Internal.fiISerializedObjectUtility:RestoreState(ISerializedObject) (at Assets/FullInspector2/Core/fiISerializedObjectUtility.cs:251)
FullInspector.BaseBehavior`1:RestoreState() (at Assets/FullInspector2/Core/BaseBehavior.cs:65)
FullInspector.Internal.fiSerializationManager:DoDeserialize(ISerializedObject) (at Assets/FullInspector2/Core/fiSerializationManager.cs:210)
FullInspector.Internal.fiSerializationManager:OnUnityObjectDeserialize(ISerializedObject) (at Assets/FullInspector2/Core/fiSerializationManager.cs:117)
FullInspector.BaseBehavior`1:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at Assets/FullInspector2/Core/BaseBehavior.cs:132)
jacobdufault commented 7 years ago

I've landed ff08d3e290c8128834a913f763a62eaad645066c which should fix the ToString call.

SharedInstance still worked for me though on Unity 5.5b8, but there is a generated exception when you change the SharedInstance type, ie, from SharedInstance<int> to SharedInstance<bool>.

jacobdufault commented 7 years ago

I've pushed a build for this commit, DLLs should be available shortly here.