Skip to content

Instantly share code, notes, and snippets.

@bwheatley
Created March 3, 2018 13:02
Show Gist options
  • Save bwheatley/9670359edf13eeaac053e37a89553be4 to your computer and use it in GitHub Desktop.
Save bwheatley/9670359edf13eeaac053e37a89553be4 to your computer and use it in GitHub Desktop.
Being able to serialize a class with generics in Unity Inspector
public class CameraSettingsGeneric<T, U>
{
[HideInInspector] public T camera;
public float minZoom = 1f;
public float maxZoom = 5f;
public float zoomAmount = 5f;
[HideInInspector]
//public CraftFacade followObject;
public U followObject;
public bool disableMouse;
}
[Serializable]
public class Settings : CameraSettingsGeneric<tk2dCamera, CraftFacade> {
}
@bwheatley
Copy link
Author

When you create the subclass as a child of CameraSettingsGeneric you're able to serialize the subclass in unity's inspector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment