Hi!
Can I somehow embed default SharedVariable drawer into my CustomObjectDrawer OnGUI method?
I have a custom serializable struct which I use as a public field for a handful of custom tasks. This struct has a CustomObjectDrawer which works fine. Now i want to add public SharedVariable field to this struct and be able to use default SharedVariable drawer inside my CustomObjectDrawer as I see fit without rewriting it from scratch.
This works just fine, but now I want to change SceneObject.gameObject field type to SharedGameObject and have this magic circle button appear in my custom drawer
Is there any way I can call a SharedGameObject drawer from my custom OnGUI?
Can I somehow embed default SharedVariable drawer into my CustomObjectDrawer OnGUI method?
I have a custom serializable struct which I use as a public field for a handful of custom tasks. This struct has a CustomObjectDrawer which works fine. Now i want to add public SharedVariable field to this struct and be able to use default SharedVariable drawer inside my CustomObjectDrawer as I see fit without rewriting it from scratch.
C#:
[System.Serializable]
public struct SceneObject
{
public enum ValueType {
UseGameObject,
UseWaypointKey
}
public ValueType valueType;
public GameObject gameObject;
public string waypointKey;
}
[CustomObjectDrawer(typeof(SceneObject))]
public class SceneObjectDrawer : ObjectDrawer
{
public override void OnGUI(GUIContent label)
{
SceneObject target = (SceneObject)value;
EditorGUI.BeginChangeCheck();
switch (target.valueType)
{
case SceneObject.ValueType.UseGameObject : {
target.gameObject = (GameObject)EditorGUILayout.ObjectField(label, target.gameObject, typeof(UnityEngine.GameObject), true);
break;
}
case SceneObject.ValueType.UseWaypointKey : {
target.waypointKey = EditorGUILayout.TextField(label, target.waypointKey);
break;
}
}
target.valueType = (SceneObject.ValueType)EditorGUILayout.EnumPopup(target.valueType, GUILayout.MaxWidth(EditorGUIUtility.singleLineHeight));
if(EditorGUI.EndChangeCheck())
{
value = target;
}
}
}
Is there any way I can call a SharedGameObject drawer from my custom OnGUI?