示例#1
0
 private static System.Action <SerializedType> BuildSerializedTypeCallback(Variant param)
 {
     return(type =>
     {
         param.SetAs <SerializedType>(type);
     });
 }
示例#2
0
 private static System.Action <System.Type> BuildDerivedTypeCallback(Variant param, System.Type baseType)
 {
     return(type =>
     {
         param.SetAs <DerivedType>(new DerivedType(baseType, type));
     });
 }
示例#3
0
        private static void LayoutAsVec2(Variant parameter, bool label)
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (label)
                {
                    parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth));
                }

                var result = EditorGUILayout.Vector2Field(GUIContent.none, parameter.GetAs <Vector2>(), GUILayout.Width(FieldWidth));
                parameter.SetAs(result);
            }
            EditorGUILayout.EndHorizontal();
        }
示例#4
0
        private static void LayoutAsCurve(Variant parameter, bool label)
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (label)
                {
                    parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth));
                }

                var result = EditorGUILayout.CurveField(parameter.GetAs <AnimationCurve>(), GUILayout.Width(FieldWidth));
                parameter.SetAs(result);
            }
            EditorGUILayout.EndHorizontal();
        }
示例#5
0
        private static void LayoutAsObject <T>(Variant parameter, bool label) where T : UnityEngine.Object
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (label)
                {
                    parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth));
                }

                T result = (T)EditorGUILayout.ObjectField(parameter.GetAs <T>(), parameter.HoldType.Type, true, GUILayout.Width(FieldWidth));
                parameter.SetAs(result);
            }
            EditorGUILayout.EndHorizontal();
        }
示例#6
0
        private static void LayoutAsGenericObject(Variant parameter, bool label)
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (label)
                {
                    parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth));
                }

                var result = EditorGUILayout.ObjectField(parameter.GetAs <Object>(), parameter.HoldType.Type, true, GUILayout.Width(FieldWidth));
                parameter.SetAs(result);
            }
            EditorGUILayout.EndHorizontal();
        }
示例#7
0
        private static void DrawAsVec2(Rect rect, Variant parameter, bool label)
        {
            if (label)
            {
                var width = rect.width;
                rect.width = width * 0.45f;

                parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel);

                rect.width = width * 0.5f;
                rect.x    += rect.width;
            }

            var result = EditorGUI.Vector2Field(rect, GUIContent.none, parameter.GetAs <Vector2>());

            parameter.SetAs(result);
        }
示例#8
0
        private static void DrawAsCurve(Rect rect, Variant parameter, bool label)
        {
            if (label)
            {
                var width = rect.width;
                rect.width = width * 0.45f;

                parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel);

                rect.width = width * 0.5f;
                rect.x    += rect.width;
            }

            var result = EditorGUI.CurveField(rect, parameter.GetAs <AnimationCurve>());

            parameter.SetAs(result);
        }
示例#9
0
        private static void DrawAsGenericObject(Rect rect, Variant parameter, bool label)
        {
            if (label)
            {
                var width = rect.width;
                rect.width = width * 0.45f;

                parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel);

                rect.width = width * 0.5f;
                rect.x    += rect.width;
            }

            var result = EditorGUI.ObjectField(rect, parameter.GetAs <Object>(), parameter.HoldType.Type, true);

            parameter.SetAs(result);
        }
示例#10
0
        private static void DrawAsObject <T>(Rect rect, Variant parameter, bool label) where T : UnityEngine.Object
        {
            if (label)
            {
                var width = rect.width;
                rect.width = width * 0.45f;

                parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel);

                rect.width = width * 0.5f;
                rect.x    += rect.width;
            }

            T result = (T)EditorGUI.ObjectField(rect, parameter.GetAs <T>(), parameter.HoldType.Type, true);

            parameter.SetAs(result);
        }
示例#11
0
        private static void DrawAsFloat(Rect rect, Variant parameter, bool label)
        {
            if (label)
            {
                var width = rect.width;
                rect.width = width * 0.45f;

                parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel);

                rect.width = width * 0.5f;
                rect.x    += rect.width;
            }

            var oldWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 13;

            var result = EditorGUI.FloatField(rect, new GUIContent("F"), parameter.GetAs <float>());

            parameter.SetAs(result);

            EditorGUIUtility.labelWidth = oldWidth;
        }
示例#12
0
        private static void DrawAsBool(Rect rect, Variant parameter, bool label)
        {
            if (label)
            {
                var width = rect.width;
                rect.width = rect.width * 0.45f;

                parameter.Name = EditorGUI.TextField(rect, parameter.Name, SpaceEditorStyles.EditableLabel);

                rect.width = width * 0.5f;
                rect.x    += rect.width + 2;
            }

            rect.width *= 0.5f;
            rect.y     -= 1;
            var result = EditorGUI.Toggle(rect, GUIContent.none, parameter.GetAs <bool>());

            parameter.SetAs(result);

            rect.y += 1;
            rect.x += 20;

            GUI.Label(rect, result.ToString(), EditorStyles.label);
        }
示例#13
0
 public void SetTo(Variant parameter)
 {
     parameter.SetAs <T>(value);
 }