public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            Rect rect = new Rect(position.x + PopupAnimationDrawer.padding, position.y,
                                 position.width - PopupAnimationDrawer.padding * 2, EditorGUIUtility.singleLineHeight);

            if (GUI.Button(rect, "Set To Current"))
            {
                if (panel == null && property.serializedObject != null)
                {
                    panel = (IPanelUI)property.serializedObject.targetObject;
                    if (panel == null)
                    {
                        Debug.LogWarning("D'oh");
                    }
                }

                var rectTrans = panel.GetRect();
                Debug.Log("Scale: " + rectTrans.localScale);
                Debug.Log("Pos: " + rectTrans.localPosition);
                Debug.Log("Rot: " + rectTrans.localRotation);

                property.FindPropertyRelative("position").vector3Value    = rectTrans.localPosition;
                property.FindPropertyRelative("scale").vector3Value       = rectTrans.localScale;
                property.FindPropertyRelative("rotation").quaternionValue = rectTrans.localRotation;
            }

            rect.y += EditorGUIUtility.singleLineHeight;

            EditorGUIUtility.labelWidth = 28;
            EditorGUI.PropertyField(rect, property.FindPropertyRelative("position"));
            rect.y += EditorGUIUtility.singleLineHeight;
            EditorGUI.PropertyField(rect, property.FindPropertyRelative("scale"));
            rect.y += EditorGUIUtility.singleLineHeight;
            var        quatProp = property.FindPropertyRelative("rotation");
            Quaternion rot      = quatProp.quaternionValue;

            Vector4 rotVect = new Vector4(rot.x, rot.y, rot.z, rot.w);

            rotVect = EditorGUI.Vector4Field(rect,
                                             new GUIContent("Rot", "Quaternion Rotation"), rotVect);
            quatProp.quaternionValue
                = new Quaternion(rotVect.x, rotVect.y, rotVect.z, rotVect.w);

            EditorGUI.indentLevel = indent;
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;
            Rect rect = new Rect(position.x + PopupAnimationDrawer.padding, position.y,
                                 position.width - PopupAnimationDrawer.padding * 2, EditorGUIUtility.singleLineHeight);

            if (GUI.Button(rect, "Set To Current"))
            {
                if (panel == null && property.serializedObject != null)
                {
                    panel = (IPanelUI)property.serializedObject.targetObject;
                    if (panel == null)
                    {
                        Debug.LogWarning("D'oh");
                    }
                }

                var rt     = panel.GetRect();
                var left   = rt.offsetMin.x;
                var right  = -rt.offsetMax.x;
                var bottom = rt.offsetMin.y;
                var top    = -rt.offsetMax.y;

                property.FindPropertyRelative("left").floatValue   = left;
                property.FindPropertyRelative("top").floatValue    = top;
                property.FindPropertyRelative("right").floatValue  = right;
                property.FindPropertyRelative("bottom").floatValue = bottom;
            }

            rect.width *= .5f;
            rect.y     += EditorGUIUtility.singleLineHeight;

            EditorGUIUtility.labelWidth = 42;
            EditorGUI.PropertyField(rect, property.FindPropertyRelative("left"));
            rect.x += rect.width;
            EditorGUI.PropertyField(rect, property.FindPropertyRelative("top"));
            rect.y += EditorGUIUtility.singleLineHeight;
            EditorGUI.PropertyField(rect, property.FindPropertyRelative("bottom"));
            rect.x -= rect.width;
            EditorGUI.PropertyField(rect, property.FindPropertyRelative("right"));

            EditorGUI.indentLevel = indent;
        }
Esempio n. 3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (panel == null && property.serializedObject != null)
            {
                panel = (IPanelUI)property.serializedObject.targetObject;
            }

            Rect rect = new Rect(position.x, position.y,
                                 position.width, EditorGUIUtility.singleLineHeight);

            visible = EditorGUI.BeginFoldoutHeaderGroup(rect, visible, label);
            if (visible)
            {
                EditorGUI.DrawRect(position, eventRectColor);

                var indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;

                rect.y     += EditorGUIUtility.singleLineHeight;
                rect.width *= .5f;
                rect.width -= padding * 2;
                rect.x     += padding;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative("type"), GUIContent.none);
                rect.x += rect.width + padding * 2;
                EditorGUIUtility.labelWidth = 82;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative("timeToFinish"));

                rect.width += padding * 2;
                rect.width *= 2;
                rect.x      = position.x;
                rect.y     += EditorGUIUtility.singleLineHeight;
                switch ((PopupAnimationType)property.FindPropertyRelative("type").enumValueIndex)
                {
                case PopupAnimationType.Off:
                    break;

                case PopupAnimationType.Linear:
                case PopupAnimationType.Quadratic:
                    DrawLerpControls(rect, property);
                    break;

                case PopupAnimationType.CustomRoutine:
                    EditorGUI.PropertyField(rect, property.FindPropertyRelative("animationRoutine"), GUIContent.none);
                    break;

                case PopupAnimationType.CustomCurve:
                    EditorGUI.PropertyField(rect, property.FindPropertyRelative("animationCurve"), GUIContent.none);
                    rect.y += EditorGUIUtility.singleLineHeight;
                    DrawLerpControls(rect, property);
                    break;

                case PopupAnimationType.Anchors:
                    DrawAnchorLerpControls(rect, property);
                    break;
                }

                // Set indent back to what it was
                EditorGUI.indentLevel = indent;
            }
            EditorGUI.EndFoldoutHeaderGroup();
        }
Esempio n. 4
0
 private void Customize(IPanelUI panel)
 {
     panel.SetParent(transform);
     panel.OpenSubPanel += OpenSubPanel;
     panel.Disable();
 }