예제 #1
0
        private void RenderActionListElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            RSActionData action = m_SelectionState.Rule.Actions[index];

            Rect labelRect = rect;

            labelRect.width -= CLONE_BUTTON_WIDTH + CLONE_BUTTON_SPACING;

            string labelText = action.GetPreviewString(GetCurrentTrigger(), m_Context.Library);

            using (new RSGUI.ColorScope(action.Enabled ? Color.white : Color.gray))
            {
                EditorGUI.LabelField(labelRect, labelText);
            }

            Rect cloneRect = rect;

            cloneRect.width   = CLONE_BUTTON_WIDTH;
            cloneRect.height -= 4;
            cloneRect.x       = labelRect.xMax + CLONE_BUTTON_SPACING;

            using (new EditorGUI.DisabledScope(EditorApplication.isPlaying))
            {
                if (GUI.Button(cloneRect, "Clone"))
                {
                    RSActionData clone = action.Clone();
                    InsertAction(clone, index + 1);
                }
            }

            if (DetectContextClick(rect))
            {
                ShowActionElementContextMenu(action, index);
            }
        }
예제 #2
0
        /// <summary>
        /// Renders editor for Action info.
        /// </summary>
        static public void ActionData(UndoTarget inUndo, RSActionData ioAction, RSValidationFlags inFlags, RSValidationContext inContext)
        {
            string preview = ioAction.GetPreviewString(inContext.Trigger, inContext.Library);

            GUILayout.Label(preview, RSGUIStyles.RuleHeaderStyle);

            EditorGUILayout.Space();

            // Enabled
            bool bEnabled = EditorGUILayout.Toggle("Enabled", ioAction.Enabled);

            if (bEnabled != ioAction.Enabled)
            {
                inUndo.MarkDirty("Changed Action Enabled");
                ioAction.Enabled = bEnabled;
            }

            EditorGUILayout.Space();

            using (new EditorGUI.DisabledGroupScope(!bEnabled))
            {
                EntityScopedIdentifier action     = ValueGUILayout.ActionField(EditorGUIUtility.TrTempContent("Action"), ioAction.Action, inFlags, inContext);
                RSActionInfo           actionInfo = inContext.Library.GetAction(action.Id);

                if (action != ioAction.Action)
                {
                    bool bChangedId = ioAction.Action.Id != action.Id;

                    inUndo.MarkDirty("Changed Action", true);
                    ioAction.Action = action;

                    if (bChangedId)
                    {
                        if (actionInfo != null)
                        {
                            actionInfo.PopulateDefaultArguments(ioAction);
                        }
                        else
                        {
                            ioAction.Arguments = null;
                        }
                    }
                }

                if (actionInfo != null && ioAction.Arguments != null && ioAction.Arguments.Length > 0)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Arguments", RSGUIStyles.SubHeaderStyle);

                    for (int i = 0; i < ioAction.Arguments.Length; ++i)
                    {
                        ParameterData(inUndo, actionInfo.Parameters[i], ioAction.Arguments[i], inFlags, inContext);
                    }
                }
            }
        }