Example #1
0
        // OVERRIDERS: ----------------------------------------------------------------------------

        protected override GUIContent[] GetVariables(int allowTypesMask)
        {
            if (this.target == null)
            {
                return(new GUIContent[0]);
            }
            LocalVariables[] localVariables = LocalVariablesUtilities.GatherLocals(
                this.target, this.inChildren
                );

            List <GUIContent> variables = new List <GUIContent>();

            for (int i = 0; i < localVariables.Length; ++i)
            {
                LocalVariables local = localVariables[i];
                for (int j = 0; j < local.references.Length; ++j)
                {
                    Variable.DataType type = (Variable.DataType)local.references[j].variable.type;
                    if ((allowTypesMask & 1 << (int)type) == 0)
                    {
                        continue;
                    }

                    variables.Add(new GUIContent(
                                      " " + local.references[j].variable.name,
                                      VariableEditorUtils.GetIcon(type)
                                      ));
                }
            }

            return(variables.ToArray());
        }
        // OVERRIDERS: ----------------------------------------------------------------------------

        protected override GUIContent[] GetVariables(int allowTypesMask)
        {
            DatabaseVariables database = DatabaseVariables.Load();

            if (database == null || database.GetGlobalVariables() == null)
            {
                PreferencesWindow.OpenWindowTab("Variables");
                return(new GUIContent[0]);
            }

            GlobalVariables   globalVariables = database.GetGlobalVariables();
            List <GUIContent> variables       = new List <GUIContent>();

            for (int i = 0; i < globalVariables.references.Length; ++i)
            {
                Variable.DataType type = (Variable.DataType)globalVariables.references[i].variable.type;
                if ((allowTypesMask & 1 << (int)type) == 0)
                {
                    continue;
                }

                variables.Add(new GUIContent(
                                  " " + globalVariables.references[i].variable.name,
                                  VariableEditorUtils.GetIcon(type)
                                  ));
            }

            return(variables.ToArray());
        }
Example #3
0
        private ItemReturnOperation PaintReferenceHeader(int i, bool usingSearch)
        {
            ItemReturnOperation returnOperation = new ItemReturnOperation();

            Rect rectHeader = GUILayoutUtility.GetRect(GUIContent.none, CoreGUIStyles.GetToggleButtonNormalOn());

            if (!usingSearch)
            {
                this.PaintDragHandle(i, rectHeader);
            }

            string variableName = (this.isExpanded[i].target ? " ▾ " : " ▸ ");

            variableName += this.GetReferenceName(i);

            Texture2D variableIcon = VariableEditorUtils.GetIcon(this.GetReferenceType(i));

            GUIStyle style = (this.isExpanded[i].target
                ? CoreGUIStyles.GetToggleButtonMidOn()
                : CoreGUIStyles.GetToggleButtonMidOff()
                              );

            Rect rectDelete = new Rect(
                rectHeader.x + rectHeader.width - 25f,
                rectHeader.y,
                25f,
                rectHeader.height
                );

            Rect rectMain = new Rect(
                rectHeader.x + 25f,
                rectHeader.y,
                rectHeader.width - (25f * 2f),
                rectHeader.height
                );

            if (usingSearch)
            {
                style = (this.isExpanded[i].target
                    ? CoreGUIStyles.GetToggleButtonLeftOn()
                    : CoreGUIStyles.GetToggleButtonLeftOff()
                         );

                rectMain = new Rect(
                    rectHeader.x,
                    rectHeader.y,
                    rectHeader.width - 25f,
                    rectHeader.height
                    );
            }

            if (GUI.Button(rectMain, new GUIContent(variableName, variableIcon), style))
            {
                this.ToggleExpand(i);
            }

            GUIContent gcDelete = ClausesUtilities.Get(ClausesUtilities.Icon.Delete);

            if (GUI.Button(rectDelete, gcDelete, CoreGUIStyles.GetButtonRight()))
            {
                returnOperation.removeIndex = true;
            }

            this.PaintTags(i);
            return(returnOperation);
        }