Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Useful (?) snippet: serializable interface references

$
0
0
Normally, serialised polymorphic references are only possible through class inheritance. This snippet provides a means by which you can drag and drop persistent, serialisable references to interfaces on other Monobehaviours and GameObjects. Simply add the following code to your project:
Code (CSharp):
  1.  
  2. [System.Serializable]
  3. public class IRef<T> : ISerializationCallbackReceiver where T : class
  4. {
  5.     public UnityEngine.Object target;
  6.     public T I { get => target as T; }
  7.     public static...
Useful (?) snippet: serializable interface references

Viewing all articles
Browse latest Browse all 1466670

Trending Articles