コード例 #1
0
        private static void LayoutAsDerivedTypePicker(GenericParameter parameter, bool label)
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (label)
                {
                    parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth));
                }

                var    type    = parameter.GetAs <DerivedType>();
                string content = "None";

                if (type.BaseType != null && type.BaseType.Type != null)
                {
                    if (type.TypeValue != null && type.TypeValue.Type != null)
                    {
                        content = $"{type.TypeValue.Type.Name} ({type.BaseType.Type.Name})";
                    }
                    else
                    {
                        content = "None ({type.BaseType.Type.Name})";
                    }
                }

                if (EditorGUILayout.DropdownButton(new GUIContent(content), FocusType.Keyboard))
                {
                    SerializedType sysType = type.BaseType ?? new SerializedType(parameter.HoldType.Metadata);

                    ReferenceTypePicker.ShowWindow(sysType.Type,
                                                   BuildDerivedTypeCallback(parameter, sysType.Type),
                                                   t => t.IsSubclassOf(sysType.Type));
                }
            }
            EditorGUILayout.EndHorizontal();
        }
コード例 #2
0
        private static void DrawAsDerivedTypePicker(Rect rect, GenericParameter 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    type    = parameter.GetAs <DerivedType>();
            string content = type.DisplayedName;

            if (EditorGUI.DropdownButton(rect, new GUIContent(content), FocusType.Keyboard))
            {
                SerializedType sysType = type.BaseType ?? new SerializedType(parameter.HoldType.Metadata);

                ReferenceTypePicker.ShowWindow(sysType.Type,
                                               BuildDerivedTypeCallback(parameter, sysType.Type),
                                               t => t.IsSubclassOf(sysType.Type));
            }
        }
コード例 #3
0
        private static void LayoutAsCurve(GenericParameter 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();
        }
コード例 #4
0
        private static void LayoutAsVec2(GenericParameter 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();
        }
コード例 #5
0
        private static void LayoutAsGenericObject(GenericParameter 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();
        }
コード例 #6
0
        private static void LayoutAsObject <T>(GenericParameter 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();
        }
コード例 #7
0
        private static void DrawAsGenericObject(Rect rect, GenericParameter 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);
        }
コード例 #8
0
        private static void DrawAsObject <T>(Rect rect, GenericParameter 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);
        }
コード例 #9
0
        private static void DrawAsVec2(Rect rect, GenericParameter 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);
        }
コード例 #10
0
        private static void DrawAsCurve(Rect rect, GenericParameter 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);
        }
コード例 #11
0
        private static void LayoutAsTypePicker(GenericParameter parameter, bool label)
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (label)
                {
                    parameter.Name = EditorGUILayout.TextField(parameter.Name, GUILayout.Width(LabelWidth));
                }

                var    type    = parameter.GetAs <SerializedType>();
                string content = type.Type != null ? $"{type.Type.Name} (System.Type)" : "None (System.Type)";

                if (EditorGUILayout.DropdownButton(new GUIContent(content), FocusType.Keyboard))
                {
                    KnownTypeUtils.ShowAddParameterMenu(BuildSerializedTypeCallback(parameter));
                }
            }
            EditorGUILayout.EndHorizontal();
        }
コード例 #12
0
        private static void DrawAsTypePicker(Rect rect, GenericParameter 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    type    = parameter.GetAs <SerializedType>();
            string content = type.Type != null ? $"{type.Type.Name} (System.Type)" : "None (System.Type)";

            if (EditorGUI.DropdownButton(rect, new GUIContent(content), FocusType.Keyboard))
            {
                KnownTypeUtils.ShowAddParameterMenu(BuildSerializedTypeCallback(parameter));
            }
        }
コード例 #13
0
        private static void DrawAsFloat(Rect rect, GenericParameter 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;
        }
コード例 #14
0
        private static void DrawAsBool(Rect rect, GenericParameter 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);
        }
コード例 #15
0
 public void GetFrom(GenericParameter parameter)
 {
     value = parameter.GetAs <T>();
 }