private Rect DrawEvents(Rect pos, Rect labelPos, SerializedProperty arrayEnter, string name)
        {
            labelPos.y += DragHeight;
            DrawerHelper.BoldLabel(labelPos, name + " Events", boldStyle);

            if (arrayEnter.hasMultipleDifferentValues)
            {
                labelPos.y += DragHeight;
                EditorGUI.HelpBox(labelPos, "Cannot edit with multiple different values.", MessageType.Info);
            }
            else
            {
                labelPos.y += DragHeight;
                DrawEventArray(pos, arrayEnter, ref labelPos, boldStyle);
                GUI.Button(labelPos, "Drag event here to add to " + name + " event");
                if (labelPos.Contains(Event.current.mousePosition))
                {
                    DrawerHelper.HandleEventDrag(arrayEnter);
                }
            }
            return(labelPos);
        }
예제 #2
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            EditorGUI.BeginProperty(pos, label, prop);
            var actions = prop.FindPropertyRelative("Actions");

            var labelPos = pos;

            var labelStyle = GUI.skin.GetStyle("label");
            var alignment  = labelStyle.alignment;

            labelStyle.alignment = TextAnchor.MiddleLeft;
            ;

            labelPos.height = 14;
            DrawerHelper.BoldLabel(labelPos, prop.FindPropertyRelative("Title").stringValue, labelStyle);

            for (int i = 0; i < actions.arraySize; ++i)
            {
                var currentElement = actions.GetArrayElementAtIndex(i);
                labelPos.y     += LineHeight;
                labelPos.height = 20;
                InAudioBankLink bankLink =
                    currentElement.FindPropertyRelative("Bank").objectReferenceValue as InAudioBankLink;
                if (bankLink != null)
                {
                    GUI.Label(labelPos, bankLink.GetName, labelStyle);
                }
                else
                {
                    GUI.Label(labelPos, "Missing event", labelStyle);
                }

                Rect buttonPos = labelPos;
                buttonPos.x     = pos.width - 172; //Align to right side
                buttonPos.width = 70;
                var actionProp = currentElement.FindPropertyRelative("BankAction");
                actionProp.enumValueIndex =
                    Convert.ToInt32(EditorGUI.EnumPopup(buttonPos, (BankHookActionType)actionProp.enumValueIndex));

                buttonPos.width = 50;

                buttonPos.x = pos.width - 100; //Align to right side
                if (bankLink == null)
                {
                    GUI.enabled = false;
                }

                if (GUI.Button(buttonPos, "Find"))
                {
                    EditorWindow.GetWindow <AuxWindow>().FindBank(bankLink);
                }
                GUI.enabled     = true;
                buttonPos.x     = pos.width - 44;
                buttonPos.width = 35;
                if (GUI.Button(buttonPos, "X"))
                {
                    actions.DeleteArrayElementAtIndex(i);
                }
            }
            labelPos.y              += DragHeight + 4;
            labelPos.height          = DragHeight;
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;

            GUI.Button(labelPos, "Drag bank here for " + prop.FindPropertyRelative("Title").stringValue);
            if (labelPos.Contains(Event.current.mousePosition))
            {
                DrawerHelper.HandleBankDrag(actions);
            }

            labelStyle.alignment = alignment;
            EditorGUI.EndProperty();
        }