Exemple #1
0
    internal static void SelectAsset()
    {
        AgentGroupSettings item = EditorUtil.GetGlobalAsset <AgentGroupSettings>();

        Selection.activeObject = item;
    }
Exemple #2
0
 public static void CreateAsset()
 {
     EditorUtil.CreateAsset <AnimationCurveAsset>("AnimationCurveAsset");
 }
Exemple #3
0
        private void DrawTextList()
        {
            EditorGUILayoutUtil.DrawSeparator();

            if (!locked && !Selection.gameObjects.IsEmpty() && (roots == null || !Enumerable.SequenceEqual(roots, Selection.gameObjects)))
            {
                Clear();
                // search labels
                roots = Selection.gameObjects;
                foreach (GameObject o in roots)
                {
                    tabs.Clear();
                    foreach (UITabHandler t in o.GetComponentsInChildren <UITabHandler>(true))
                    {
                        tabs.Add(new UITabHandlerInspectorImpl(t));
                    }
                }
                foreach (GameObject o in roots)
                {
                    // remove number labels
                    HashSet <UIText> ignore = new HashSet <UIText>();

                    foreach (DropDown dropdown in o.GetComponentsInChildren <DropDown>(true))
                    {
                        foreach (UIText l in dropdown.GetComponentsInChildren <UIText>(true))
                        {
                            ignore.Add(l);
                        }
                    }

                    foreach (UIText l in o.GetComponentsInChildren <UIText>(true))
                    {
                        if (l.text.IsEmpty())
                        {
                            continue;
                        }
                        if (ignore.Contains(l))
                        {
                            continue;
                        }
                        if (visibleOnly && (!l.gameObject.activeInHierarchy || !l.enabled))
                        {
                            continue;
                        }
                        foreach (char c in l.text)
                        {
                            if (char.IsLetter(c) && !char.IsWhiteSpace(c) && !char.IsPunctuation(c))
                            {
                                labels.Add(l);
                                break;
                            }
                        }
                    }
                }
            }
            foreach (UITabHandlerInspectorImpl inspector in tabs)
            {
                if (inspector.OnInspectorGUI())
                {
                    Save();
                    roots = null;
                }
            }

            // draw trigger list
            EditorGUILayout.BeginVertical();
            foreach (UIText l in labels)
            {
                if (!mod.ContainsKey(l))
                {
                    FindKey(l);
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.ObjectField(l, typeof(UIText), true);
                Color  oldColor = GUI.backgroundColor;
                string srcKey   = mod.Get(l);
                if (srcKey == null)
                {
                    srcKey = l.textKey;
                }
                if (!Lexicon.ContainsKey(srcKey))
                {
                    GUI.backgroundColor = Color.red;
                }
                string dstKey = EditorGUILayout.TextField(srcKey);
                GUI.backgroundColor = oldColor;
                string text = EditorGUILayout.TextField(l.text);
                if (srcKey != dstKey)
                {
                    mod[l] = dstKey;
                }
                if (text != l.text)
                {
                    l.SetText(text);
                    EditorUtil.SetDirty(l);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Save"))
            {
                Save();
            }
        }
Exemple #4
0
 public void SetUp(params string[] lines)
 {
     _textBuffer = EditorUtil.CreateBuffer(lines);
     _manager    = new FoldManager(_textBuffer);
 }
        public override void OnHeaderGUI()
        {
            Validate();
            EditorGUILayout.BeginHorizontal();
            if (EditorGUIUtil.ObjectField <GameObject>("Root", ref root, true))
            {
                Refresh();
            }
            GUI.enabled = root != null;
            if (GUILayout.Button("Refresh", GUILayout.ExpandWidth(false)))
            {
                Refresh();
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
            UIPanel[] panels = root != null?root.GetComponentsInChildren <UIPanel>(true) : new UIPanel[0];

            EditorGUILayout.BeginHorizontal();
            if (EditorGUIUtil.PopupNullable("Panel", ref panelSel, panels, ObjToString.DefaultToString))
            {
                Refresh();
                if (panelSel != null)
                {
                    EditorGUIUtility.PingObject(panelSel);
                    Selection.activeGameObject = panelSel.gameObject;
                }
            }
            EditorGUIUtil.Toggle("Show Active Only", ref showActiveOnly);
            EditorGUILayout.EndHorizontal();
            UIAtlas[] atlases = GetAtlases(widgets);
            UIFont[]  fonts   = GetFonts(widgets);
            if (EditorGUIUtil.PopupNullable("Select Atlas", ref atlasSel, atlases, ObjToString.DefaultToString))
            {
                if (atlasSel != null)
                {
                    fontSel = null;
                }
            }
            if (EditorGUIUtil.PopupNullable("Select Font", ref fontSel, fonts, ObjToString.DefaultToString))
            {
                if (fontSel != null)
                {
                    atlasSel = null;
                }
            }
            EditorGUILayout.BeginHorizontal();
            int index = Array.FindIndex(widgets, w => w.gameObject == Selection.activeGameObject);

            GUI.enabled = index >= 0;
            if (GUI.enabled)
            {
                if (GUILayout.Button("+1 over selection"))
                {
                    for (int i = 0; i <= index; ++i)
                    {
                        widgets[i].depth = widgets[i].depth + 1;
                        EditorUtil.SetDirty(widgets[i]);
                    }
                }
                if (GUILayout.Button("-1 under selection"))
                {
                    for (int i = index; i < widgets.Length; ++i)
                    {
                        widgets[i].depth = widgets[i].depth - 1;
                        EditorUtil.SetDirty(widgets[i]);
                    }
                }
                // TODOM key handling
                var e = Event.current;
                if (e.type == EventType.KeyUp)
                {
                    if (e.keyCode == KeyCode.UpArrow)
                    {
                        index--;
                        if (index >= 0)
                        {
                            Select(widgets[index]);
                        }
                    }
                    else if (e.keyCode == KeyCode.DownArrow)
                    {
                        index++;
                        if (index < widgets.Length)
                        {
                            Select(widgets[index]);
                        }
                    }
                }
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
        }
    /// <summary>
    /// Gets a clone of the global  well known avoidance type names.
    /// </summary>
    /// <returns>A clone of the well known avoidance type names.</returns>
    public static string[] GetAvoidanceNames()
    {
        CAINavEditorSettings settings = EditorUtil.GetGlobalAsset <CAINavEditorSettings>();

        return((string[])settings.avoidanceNames.Clone());
    }
        private void SetTabColor(UIButton tabButton, Color inactiveTabColor, Color hoverTabColor, Color pressedTabColor, Color activeTabColor)
        {
            if (tabButton == null)
            {
                return;
            }
            UISprite sprite = tabButton.GetComponent <UISprite>();
            UILabel  label  = tabButton.GetComponentInChildren <UILabel>();

            if (label != null)
            {
                Undo.RecordObjects(new Object[] { tabButton.gameObject, label.gameObject }, "TabColor");
            }
            else
            {
                Undo.RecordObject(tabButton.gameObject, "TabColor");
            }


            if (sprite != null)
            {
                tabButton.normalSprite   = "tab_normal";
                tabButton.hoverSprite    = null;
                tabButton.pressedSprite  = null;
                tabButton.disabledSprite = "tab_selected";
                sprite.color             = Color.white;
            }
            if (label != null)
            {
                UIButtonColor[] colors = tabButton.GetComponents <UIButtonColor>();
                UIButtonColor   c      = null;
                foreach (var textCol in colors)
                {
                    if (textCol.tweenTarget == label.gameObject)
                    {
                        c = textCol;
                        break;
                    }
                }
                if (c == null)
                {
                    c = tabButton.gameObject.AddComponent <UIButtonColor>();
                }
                // add ButtonColor for Label
                label.effectStyle = UILabel.Effect.Outline;
                label.effectColor = Color.black;
                c.tweenTarget     = label.gameObject;
                EditorUtil.SetDirty(label.gameObject);
            }
            foreach (UIButtonColor c in tabButton.GetComponents <UIButtonColor>())
            {
                if (c.tweenTarget == tabButton.gameObject)
                {
                    c.tweenTarget.GetComponent <UIWidget>().color = inactiveTabColor;
                    c.hover         = hoverTabColor;
                    c.pressed       = pressedTabColor;
                    c.disabledColor = activeTabColor;
                }
            }
            EditorUtil.SetDirty(tabButton.gameObject);
        }
Exemple #8
0
        public void RemoveBuffer_ReturnFalseForNonAssociatedTextView()
        {
            var textView = EditorUtil.CreateTextView();

            Assert.IsFalse(_vim.RemoveVimBuffer(textView));
        }
Exemple #9
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public override void OnGUI(Rect pPosition, SerializedProperty pProp, GUIContent pLabel)
        {
            DisableWhenControlledAttribute attrib = (DisableWhenControlledAttribute)attribute;
            string                 mapName        = attrib.ControllerMapName;
            SerializedObject       self           = pProp.serializedObject;
            ISettingsControllerMap map            = EditorUtil.GetControllerMap(self, mapName);
            bool   wasEnabled   = GUI.enabled;
            Rect   propRect     = pPosition;
            bool   hasRangeMin  = (attrib.RangeMin != DisableWhenControlledAttribute.NullRangeMin);
            bool   hasRangeMax  = (attrib.RangeMax != DisableWhenControlledAttribute.NullRangeMax);
            bool   isControlled = (map != null && map.IsControlled(pProp.name));
            string labelText    = pLabel.text;

            if (map != null && attrib.DisplaySpecials)
            {
                List <string> specialValueNames = map.GetNewListOfControlledValueNames(true);
                Rect          specialRect       = propRect;
                specialRect.height = EditorGUIUtility.singleLineHeight;

                foreach (string specialValueName in specialValueNames)
                {
                    DrawLinkIcon(self.targetObject, map.Get(specialValueName), specialRect);
                    GUI.enabled = false;
                    EditorGUI.LabelField(specialRect, IconTextPrefix + specialValueName.Substring(1));
                    GUI.enabled    = wasEnabled;
                    specialRect.y += specialRect.height + EditorGUIUtility.standardVerticalSpacing;
                }

                propRect.y      = specialRect.y;
                propRect.height = specialRect.height;
            }

            if (isControlled)
            {
                ISettingsController settingsController = map.Get(pProp.name);
                DrawLinkIcon(self.targetObject, settingsController, propRect);
                pLabel.text = IconTextPrefix + labelText;
            }
            else
            {
                pLabel.text = labelText;
            }

            GUI.enabled = !isControlled;
            vWidth      = pPosition.width;

            if (hasRangeMin && hasRangeMax)
            {
                EditorGUI.Slider(propRect, pProp, attrib.RangeMin, attrib.RangeMax, pLabel);
            }
            else
            {
                EditorGUI.PropertyField(propRect, pProp, pLabel, true);

                if (hasRangeMin)
                {
                    pProp.floatValue = Mathf.Max(pProp.floatValue, attrib.RangeMin);
                }
                else if (hasRangeMax)
                {
                    pProp.floatValue = Mathf.Min(pProp.floatValue, attrib.RangeMax);
                }
            }

            GUI.enabled = wasEnabled;
        }
Exemple #10
0
    /// <summary>
    /// Coroutine for generate the board
    /// </summary>
    private IEnumerator GenerateBoardInternal()
    {
        // Get the board object
        var board = FindOrCreateBoardObject();

        board.Size = new Vector2Int(m_SizeX, m_SizeY);

        // Clean up all childrens
        Transform boardTransform = null; //board.transform;

        if (boardTransform != null)
        {
            EditorUtil.DestroyChildren(boardTransform);
        }
        else
        {
            foreach (var cell in FindObjectsOfType <Cell>())
            {
                DestroyImmediate(cell.gameObject);
            }

            foreach (var cell in FindObjectsOfType <Wall>())
            {
                DestroyImmediate(cell.gameObject);
            }

            foreach (var cell in FindObjectsOfType <HomebaseAuthoring>())
            {
                DestroyImmediate(cell.gameObject);
            }

            foreach (var cell in FindObjectsOfType <Spawner_Authoring>())
            {
                DestroyImmediate(cell.gameObject);
            }
        }

        // Generate the board floor and external walls
        for (int z = 0; z < m_SizeY; ++z)
        {
            for (int x = 0; x < m_SizeX; ++x)
            {
                var coord = new Vector2Int(x, z);

                var index = (coord.x + coord.y) % 2 == 0 ? 1 : 0;

                var obj = Instantiate <GameObject>(m_CellPrefab);
                obj.name = "board_" + coord;
                obj.transform.SetParent(boardTransform);

                var cell = obj.GetComponent <Cell>();
                if (cell == null)
                {
                    cell = obj.AddComponent <Cell>();
                }
                cell.location = coord;
                cell.isHole   = false;

                // Position the block
                obj.transform.localPosition = new Vector3(
                    coord.x,
                    UnityEngine.Random.value * m_YNoise,
                    coord.y);

                PlaceWall(Directions.North, coord + Vector2Int.up, boardTransform, coord.y == m_SizeY - 1);
                PlaceWall(Directions.East, coord + Vector2Int.right, boardTransform, coord.x == m_SizeX - 1);
                PlaceWall(Directions.South, coord, boardTransform, coord.y == 0);
                PlaceWall(Directions.West, coord, boardTransform, coord.x == 0);

                m_GeneratingProgress++;
            }

            yield return(null);
        }


        var oldState = UnityEngine.Random.state;

        if (m_RandomSeed != -1)
        {
            UnityEngine.Random.InitState(m_RandomSeed);
        }

        var wallMap = board.GetWalls();

        // Create random Walls
        int numWalls = (int)(m_SizeX * m_SizeY * 0.2f);

        for (int c = 0; c < numWalls; ++c)
        {
            var location  = new Vector2Int(UnityEngine.Random.Range(0, m_SizeX), UnityEngine.Random.Range(0, m_SizeY));
            var direction = GetRandomDirection();

            // Avoid wall outside the board
            if (location.x == 0)
            {
                if (direction == Directions.West || direction == Directions.East)
                {
                    continue;
                }
            }

            if (location.y == 0)
            {
                if (direction == Directions.North || direction == Directions.South)
                {
                    continue;
                }
            }

            if (BoardAuthoring.HasWall(wallMap, location, direction))
            {
                continue;
            }

            int count = 0;
            if (direction != Directions.North && BoardAuthoring.HasWall(wallMap, location, Directions.North))
            {
                count++;
            }
            if (direction != Directions.East && BoardAuthoring.HasWall(wallMap, location, Directions.East))
            {
                count++;
            }
            if (direction != Directions.South && BoardAuthoring.HasWall(wallMap, location, Directions.South))
            {
                count++;
            }
            if (direction != Directions.West && BoardAuthoring.HasWall(wallMap, location, Directions.West))
            {
                count++;
            }

            // Avoid closed cells
            if (count >= 3)
            {
                continue;
            }

            var wall = PlaceWall(direction, location, boardTransform);
            BoardAuthoring.AddWallToDictionary(ref wallMap, wall);
        }

        // Setup home bases
        var offset = 1f / 3f;
        var placeX = m_SizeX * offset;
        var placeY = m_SizeY * offset;

        // Setup holes
        var cellMap = board.GetCellMap();

        PlaceHomebase(Players.Player1, placeX, placeY, boardTransform, cellMap);
        PlaceHomebase(Players.Player2, placeX * 2f, placeY, boardTransform, cellMap);
        PlaceHomebase(Players.Player3, placeX * 2f, placeY * 2f, boardTransform, cellMap);
        PlaceHomebase(Players.Player4, placeX, placeY * 2f, boardTransform, cellMap);

        // Setup spawners
        if (!m_NoDefaultSpawners)
        {
            PlaceSpawner(0, 0, boardTransform, Quaternion.identity, cellMap);
            PlaceSpawner(m_SizeX - 1, 0, boardTransform, Quaternion.Euler(0, 0, 0), cellMap);
            PlaceSpawner(m_SizeX - 1, m_SizeY - 1, boardTransform, Quaternion.identity, cellMap);
            PlaceSpawner(0, m_SizeY - 1, boardTransform, Quaternion.Euler(0, 0, 0), cellMap);
        }

        int additionalSpawners = m_AdditionalSpawners;

        while (additionalSpawners > 0)
        {
            var coord = new Vector2Int(UnityEngine.Random.Range(0, m_SizeX), UnityEngine.Random.Range(0, m_SizeY));
            if (coord.x > 0 && coord.y > 0 && coord.x < m_SizeX - 1 && coord.y < m_SizeY - 1 && cellMap.ContainsKey(coord))
            {
                var cell = cellMap[coord];
                if (cell.hasSpawner || cell.homebase != null)
                {
                    continue;
                }

                PlaceSpawner(coord.x, coord.y, boardTransform, Quaternion.identity, cellMap);
                additionalSpawners--;
            }
        }

        if (!m_NoHoles)
        {
            int numHoles = (int)(m_SizeX * m_SizeY * 0.05f);
            for (int i = 0; i < numHoles; ++i)
            {
                var coord = new Vector2Int(UnityEngine.Random.Range(0, m_SizeX), UnityEngine.Random.Range(0, m_SizeY));
                if (coord.x > 0 && coord.y > 0 && coord.x < m_SizeX - 1 && coord.y < m_SizeY - 1 && cellMap.ContainsKey(coord))
                {
                    var cell = cellMap[coord];
                    if (cell.isHole || cell.hasSpawner || cell.homebase != null)
                    {
                        continue;
                    }

                    var holeObject = new GameObject();
                    holeObject.name = "hole_" + coord;
                    holeObject.transform.SetParent(boardTransform);
                    holeObject.transform.localPosition = cell.transform.localPosition;

                    var holeCell = holeObject.AddComponent <Cell>();
                    holeCell.location = coord;
                    holeCell.isHole   = true;

                    cellMap[coord] = holeCell;
                    DestroyImmediate(cell.gameObject);
                }
            }
        }

        UnityEngine.Random.state = oldState;

        Debug.Log("Board Generated!");
        m_IsGenerating = false;
    }
        //------------------------------------------------------------------------------
        private void TemplateDetailsGUI()
        {
            if (m_targetTemplate.TemplateElements.Count <= 0)
            {
                return;
            }


            EditorGUILayout.LabelField("Element Details", new GUIStyle("OL Title"));

            Rect elementDetailsRect = EditorGUILayout.BeginVertical(m_elementSelectionBgStyle);

            TemplateElement element = m_targetTemplate.TemplateElements[m_selectedElement];

            String     elementNameTooltip = "Token for use in the %ELEMENT_NAME()% substition when referring to other elements in a template.";
            GUIContent elementNameContent = new GUIContent("Element Name", elementNameTooltip);

            element.ElementName = FilterElementName(EditorGUILayout.TextField(elementNameContent, element.ElementName));

            String     templateTokenFormatTooltip = "C# style Format string used to generate the template token and file name for the output of this element. {0} will be replaced by the user supplied token when the template is instantiated.";
            GUIContent templateTokenFormatContent = new GUIContent("Template Token Format", templateTokenFormatTooltip);

            element.TemplateTokenFormat = FilterFileNameFormat(EditorGUILayout.TextField(templateTokenFormatContent, element.TemplateTokenFormat));

            String     fileExtensionTooltip = "Optional file extension used when generating the file name for the output of this element.";
            GUIContent fileExtensionContent = new GUIContent("File Extension", fileExtensionTooltip);

            element.Extension = FilterExtension(EditorGUILayout.TextField(fileExtensionContent, element.Extension));

            EditorGUILayout.Space();

            try {
                String exampleFileName = String.Format(element.TemplateTokenFormat, "Example");
                String exampleHelpText = String.Format("Example generated file name: \"{0}{1}\"", exampleFileName, element.Extension);
                EditorGUILayout.HelpBox(exampleHelpText, MessageType.Info);
            } catch (Exception) {
                EditorGUILayout.HelpBox("Invalid file name format.  Please use {0} to insert the user specified name into the file name.", MessageType.Error);
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Contents", EditorStyles.largeLabel);
            GUILayout.FlexibleSpace();

            String     importTooltip = "Import a file to populate this template element.";
            GUIContent importContent = new GUIContent("Import...", importTooltip);

            bool importFile = GUILayout.Button(importContent, EditorStyles.miniButton);

            if (importFile)
            {
                String path = EditorUtility.OpenFilePanel("Import code file", "", "");
                if (!String.IsNullOrEmpty(path))
                {
                    using (System.IO.StreamReader fileReader = System.IO.File.OpenText(path)) {
                        element.Contents = fileReader.ReadToEnd();
                    }
                    GUI.FocusControl(String.Empty);
                }
            }
            EditorGUILayout.EndHorizontal();

            m_scrollState = EditorGUILayout.BeginScrollView(m_scrollState, GUILayout.ExpandHeight(true));

            String uiNormalizedContents = EditorUtil.NormalizeLineEndings(element.Contents, EditorUtil.EolType.Unix);

            if (uiNormalizedContents.Length <= EditorUtil.MaxTextAreaStringLength)
            {
                // Our template is at an editable length
                String rawContents = EditorGUILayout.TextArea(uiNormalizedContents, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));

                // If editing has made the template too long then we trim it and force the
                // TextArea to update by removing focus
                if (rawContents.Length > EditorUtil.MaxTextAreaStringLength)
                {
                    rawContents = rawContents.Substring(0, EditorUtil.MaxTextAreaStringLength);
                    GUI.FocusControl(String.Empty);
                }

                if (GUI.changed)
                {
                    element.Contents = EditorUtil.NormalizeLineEndings(rawContents, TemplatePrefs.Eol);
                }
            }
            else
            {
                // Template is not at an editable length
                EditorGUILayout.HelpBox("Template is too long for editing.  Please import a shorter template.", MessageType.Error);
            }


            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndVertical();

            // Cache the rect for this UI area for later use in drag & drop operations
            if (Event.current.type == EventType.Repaint)
            {
                m_elementDetailsRect = elementDetailsRect;
            }
        }
        //绘制状态
        void DrawState(StateHandle.State s, int idx)
        {
            if (!EditorUtil.DrawHeader("状态-" + s.name, "StateHandle_state_" + idx))
            {
                return;
            }

            bool syncGo = idx == m_cur.m_curState;//如果改变值的话要不要改变游戏变量

            using (new AutoContent())
            {
                //状态的信息
                using (new AutoBeginHorizontal())
                {
                    GUI.changed = false;
                    s.name      = EditorGUILayout.TextField("名字", s.name);//名字
                    using (new AutoLabelWidth(30))
                    {
                        s.isDuration = EditorGUILayout.Toggle("渐变", s.isDuration, GUILayout.Width(45));//渐变
                    }
                    //上移
                    if (m_cur.CanMoveState(idx, true) && GUILayout.Button("上移", GUILayout.Width(40)))
                    {
                        m_cur.MoveState(idx, true);
                        return;
                    }
                    //下移
                    if (m_cur.CanMoveState(idx, false) && GUILayout.Button("下移", GUILayout.Width(40)))
                    {
                        m_cur.MoveState(idx, false);
                        return;
                    }
                    if (GUILayout.Button("删除", GUILayout.Width(40)))
                    {
                        m_cur.RemoveState(idx);
                        return;
                    }

                    if (GUI.changed)
                    {
                        EditorUtil.SetDirty(m_cur);
                    }
                }
                using (new AutoBeginHorizontal()) //音效,位置不够另起一行
                {
                    EditorGUILayout.LabelField("音效", GUILayout.Width(85));
                    using (new AutoLabelWidth(30))
                    {
                        s.isEnterSound = EditorGUILayout.Toggle("进入", s.isEnterSound, GUILayout.Width(45));
                        if (s.isEnterSound)
                        {
                            int.TryParse(EditorGUILayout.TextField("ID", s.enterSoundId.ToString(), GUILayout.Width(60)), out s.enterSoundId);
                        }
                    }

                    using (new AutoLabelWidth(30))
                    {
                        s.isExitSound = EditorGUILayout.Toggle("离开", s.isExitSound, GUILayout.Width(45));
                        if (s.isExitSound)
                        {
                            int.TryParse(EditorGUILayout.TextField("ID", s.exitSoundId.ToString(), GUILayout.Width(60)), out s.exitSoundId);
                        }
                    }
                }

                //共有操作,不用画对象,也不能在这删除它
                for (int i = 0; i < s.publicHandles.Count; ++i)
                {
                    Handle h = s.publicHandles[i];
                    if (h.CurHandle == null)
                    {
                        //Debuger.LogError("没有处理");
                        continue;
                    }

                    using (new AutoBeginHorizontal())
                    {
                        EditorGUILayout.LabelField(h.CurTypeName, GUILayout.Width(85));
                        using (new AutoBeginVertical())
                        {
                            using (new AutoLabelWidth(50))
                            {
                                h.CurHandle.OnDrawMin(m_cur, h, SimpleHandleEditor.OnOpenWnd, syncGo);
                            }
                        }
                    }
                }

                //私有操作
                for (int i = 0; i < s.privateHandles.Count; ++i)
                {
                    Handle h = s.privateHandles[i];
                    if (h.CurHandle == null)
                    {
                        //Debuger.LogError("没有处理");
                        continue;
                    }

                    //对象和删除操作
                    using (new AutoBeginHorizontal())
                    {
                        //游戏对象改变
                        if (h.CurHandle.OnDrawGo(m_cur, h, h.CurTypeName))
                        {
                            h.CurHandle.OnReset(h, false, true);
                        }

                        //删除
                        if (GUILayout.Button("删除", GUILayout.Width(40)))
                        {
                            m_cur.RemovePrivateHandle(idx, i);
                            return;
                        }
                    }
                    //内容
                    using (new AutoBeginHorizontal())
                    {
                        EditorGUILayout.LabelField("", GUILayout.Width(85));
                        using (new AutoBeginVertical())
                        {
                            using (new AutoLabelWidth(50))
                            {
                                h.CurHandle.OnDrawMin(m_cur, h, SimpleHandleEditor.OnOpenWnd, syncGo);
                            }
                        }
                    }
                }

                //增加私有操作
                int type = UnityEditor.EditorGUILayout.Popup("增加私有操作", -1, Handle.TypeName);
                if (type != -1 && type != 0)
                {
                    m_cur.AddPrivateHandle(idx, (Handle.Type)type);
                }
            }
        }
Exemple #13
0
        private void DrawAudioTriggers()
        {
            EditorGUIUtil.Toggle("Lock", ref locked);
            // set missing triggers
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Missing");
            if (missingTriggerInspector.DrawInspectorGUI(ref missingTable, ref missingClip) && missingClip.IsNotEmpty())
            {
                foreach (AudioTriggerInspectorImpl i in triggers)
                {
                    if (i.trigger.audioGroupGuid.IsEmpty() || i.trigger.clip.IsEmpty())
                    {
                        i.SelectTable(missingTable);
                        i.trigger.clip = missingClip;
                        EditorUtil.SetDirty(i.trigger);
                        changedList.Add(i.trigger.gameObject);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUIUtil.DrawSeparator();
            // Search AudioTriggers
            if ((roots.IsEmpty() || !locked) && Selection.gameObjects.IsNotEmpty() && !Array.Equals(roots, Selection.gameObjects))
            {
                Clear();
                roots = Selection.gameObjects;
                List <AudioTrigger> audio = new List <AudioTrigger> ();
                foreach (GameObject o in roots)
                {
                    foreach (UIButton btn in o.GetComponentsInChildren <UIButton>(true))
                    {
                        AudioTrigger[] t = btn.GetComponents <AudioTrigger> ();
                        if (t.IsEmpty())
                        {
                            t = new AudioTrigger[] { btn.gameObject.AddComponent <AudioTrigger> () };
                            changedList.Add(btn.gameObject);
                            EditorUtil.SetDirty(btn.gameObject);
                        }
                        audio.AddRange(t);
                    }
                }
                AudioDataTable[] tables = AudioTriggerInspectorImpl.LoadTables();
                triggers = new AudioTriggerInspectorImpl[audio.Count];
                for (int i = 0; i < audio.Count; ++i)
                {
                    triggers [i]           = new AudioTriggerInspectorImpl(audio [i], tables);
                    triggers [i].showLabel = false;
                }
            }

            // draw trigger list
            EditorGUILayout.BeginVertical();
            foreach (AudioTriggerInspectorImpl a in triggers)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.ObjectField(a.trigger.gameObject, typeof(GameObject), true);
                if (a.DrawInspectorGUI())
                {
                    changedList.Add(a.trigger.gameObject);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Save"))
            {
                SaveChange(changedList);
                changedList.Clear();
            }
        }
Exemple #14
0
 public void Create(params string[] lines)
 {
     _buffer = EditorUtil.CreateTextBuffer(lines);
 }
        public bool OnInspectorGUI()
        {
            bool changed = tabArrInspector.OnInspectorGUI();

            changed |= tabPrefabArrInspector.OnInspectorGUI();
            if (tabPrefabArrInspector.Length > 0)
            {
                tabButtonArrInspector.DoLayoutList();
            }
            if (GUILayout.Button("Reallocate"))
            {
                tabHandler.tabs = new List <UITab>();
                foreach (UITab t in tabHandler.GetComponentsInChildren <UITab>(true))
                {
                    tabHandler.tabs.Add(t);
                    OnTabChanged(t, 0);
                }
                EditorUtil.SetDirty(tabHandler);
                //          for (int i=0; i<tabHandler.tabs.Length; ++i) {
                //              UITab t = tabHandler.tabs[i];
                //              OnTabRemoved(t, 0);
                //              OnTabChanged(t, 0);
                //          }
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUIUtil.ObjectField <UIButton>(ref button, true);
            EditorGUILayout.EndHorizontal();

            foreach (UITab t in tabHandler.tabs)
            {
                if (t != null)
                {
                    if (t.tabButton == null)
                    {
                        EditorGUILayout.HelpBox(t.name + " Tab Button is null", MessageType.Error);
                    }
                    if (t.uiRoot == null)
                    {
                        EditorGUILayout.HelpBox(t.name + " Tab Root is null", MessageType.Error);
                    }
                }
            }
            HashSet <GameObject> activeTabs = new HashSet <GameObject>();

            foreach (UITab t in tabHandler.tabs)
            {
                if (t != null && t.IsVisible())
                {
                    activeTabs.Add(t.uiRoot);
                }
            }
            if (activeTabs.Count > 1)
            {
                EditorGUILayout.HelpBox("Multiple Tabs are activated", MessageType.Error);
                if (GUILayout.Button("Fix"))
                {
                    tabHandler.Init(tabHandler);
                    foreach (UITab t in tabHandler.tabs)
                    {
                        if (t != null)
                        {
                            EditorUtil.SetDirty(t.uiRoot);
                        }
                    }
                }
            }
            return(changed);
        }
Exemple #16
0
 static void MenuItem()
 {
     EditorUtil.CreatePrefab("ScrollView", SCROLLVIEW_PREFAB_PATH, true);
 }
Exemple #17
0
 virtual public void DrawDebug(RectIntExclusive area)
 {
     EditorUtil.DrawRect(Map.instance, area, Color.green);
 }
Exemple #18
0
        public override void OnInspectorGUI()
        {
            object current = null;

            Color contentColor = GUI.contentColor;
            Color bgColor      = GUI.backgroundColor;
            Color c1           = BG_COLOR1;
            Color c2           = BG_COLOR1;

            foreach (UIWidget w in widgets)
            {
                if (w.GetType() == typeof(UIWidget) || w.gameObject == null)
                {
                    continue;
                }
                UISprite  s     = w as UISprite;
                UILabel   l     = w as UILabel;
                UITexture t     = w as UITexture;
                int       depth = w.depth;

                #pragma warning disable 0253
                bool toggle = false;
                if (s != null)
                {
                    if (s.atlas == null)
                    {
                        continue;
                    }
                    if (s.atlas != current)
                    {
                        current = s.atlas;
                        toggle  = true;
                    }
                }
                else if (l != null)
                {
                    if (l.bitmapFont != current)
                    {
                        current = l.bitmapFont;
                        toggle  = true;
                    }
                }
                else if (t != null)
                {
                    if (t.mainTexture != current)
                    {
                        current = t.mainTexture;
                        toggle  = true;
                    }
                }
                else
                {
                    toggle  = true;
                    current = null;
                }
                #pragma warning restore 0253
                if (toggle)
                {
                    c2 = c2 != BG_COLOR1? BG_COLOR1: BG_COLOR2;
                }
                c1 = c2;

                if (atlasSel != null)
                {
                    c1 = s != null && s.atlas == atlasSel? SEL_BG_COLOR: BG_COLOR1;
                }
                else if (fontSel != null)
                {
                    c1 = l != null && l.bitmapFont == fontSel? SEL_BG_COLOR: BG_COLOR1;
                }
                if (w.gameObject == Selection.activeGameObject)
                {
                    c1 = SEL_BG_COLOR;
                }
                GUI.backgroundColor = c1;
                if (c1 == BG_COLOR1)
                {
                    GUI.contentColor = TXT_COLOR1;
                }
                else if (c1 == BG_COLOR2)
                {
                    GUI.contentColor = TXT_COLOR2;
                }
                else if (c1 == SEL_BG_COLOR)
                {
                    GUI.contentColor = SEL_TXT_COLOR;
                }

                EditorGUILayout.BeginHorizontal();
                string widgetName = w.name;
                if (s != null)
                {
                    if (s.atlas != null)
                    {
                        widgetName = string.Format("[ATLAS {0}] {2} ({1})", s.atlas.name, s.spriteName, w.name);
                    }
                }
                else if (l != null)
                {
                    if (l.trueTypeFont != null)
                    {
                        widgetName = string.Format("[TTF {0}] {1}", l.trueTypeFont.name, w.name);
                    }
                    else if (l.bitmapFont != null)
                    {
                        widgetName = string.Format("[BMF {0}] {1}", l.bitmapFont.name, w.name);
                    }
                    else
                    {
                        widgetName = string.Format("FNT {0}", w.name);
                    }
                }
                else if (t != null)
                {
                    if (t.mainTexture != null)
                    {
                        widgetName = string.Format("[TEX {0}] {1}", t.mainTexture.name, t.name);
                    }
                    else
                    {
                        widgetName = string.Format("TEX {0}", t.name);
                    }
                }
                bool active = w.gameObject.activeInHierarchy;
                if (active || !showActiveOnly)
                {
                    Color fgColor = Color.white;
                    if (!active)
                    {
                        fgColor = INACTIVE_TXT_COLOR;
                    }
                    GUI.contentColor = fgColor;
                    if (GUILayout.Button(widgetName, EditorStyles.objectField))
                    {
                        Select(w);
                    }
                    if (EditorGUIUtil.IntField(null, ref depth, GUILayout.Width(40)))
                    {
                        w.depth = depth;
                        EditorUtil.SetDirty(w);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            GUI.backgroundColor = bgColor;
            GUI.contentColor    = contentColor;
        }
Exemple #19
0
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();
        SimpleRole r = target as SimpleRole;

        EditorGUI.BeginChangeCheck();
        r.m_showDebug = EditorGUILayout.Toggle("显示调试界面", r.m_showDebug);
        r.m_isEmpty   = EditorGUILayout.Toggle("无模型角色", r.m_isEmpty);
        if (!r.m_isEmpty)
        {
            EditorGUILayout.Space();
            r.m_moveAniSpeed = EditorGUILayout.FloatField("跑步动作调整(防滑步)", r.m_moveAniSpeed);
            r.m_moveSpeed    = EditorGUILayout.FloatField("跑步速度", r.m_moveSpeed);
            r.m_needFade     = EditorGUILayout.Toggle("是否渐变", r.m_needFade);
            if (r.m_needFade)
            {
                r.m_fade = EditorGUILayout.FloatField("所有被击渐变时间", r.m_fade);
            }
            r.m_needResetPos = EditorGUILayout.Toggle("是否复位", r.m_needResetPos);
            EditorGUILayout.Space();
            r.m_behitDuration = EditorGUILayout.FloatField("被击时间", r.m_behitDuration);
            EditorGUILayout.Space();
            r.m_floatBehitStartSpeed  = EditorGUILayout.FloatField("被击时的初速度", r.m_floatBehitStartSpeed);
            r.m_floatBehitAccelerated = EditorGUILayout.FloatField("被击时的加速度", r.m_floatBehitAccelerated);
            r.m_floatStartSpeed       = EditorGUILayout.FloatField("浮空初速度", r.m_floatStartSpeed);
            r.m_floatAcceleratedUp    = EditorGUILayout.FloatField("上升时的加速度", r.m_floatAcceleratedUp);
            r.m_floatAcceleratedDown  = EditorGUILayout.FloatField("下落时的加速度", r.m_floatAcceleratedDown);
            r.m_floatSpeedUpLimit     = EditorGUILayout.FloatField("速度上限", r.m_floatSpeedUpLimit);
            r.m_floatSpeeDownLimit    = EditorGUILayout.FloatField("速度下限", r.m_floatSpeeDownLimit);
            EditorGUILayout.Space();
            r.m_flyStartSpeed      = EditorGUILayout.FloatField("击飞初速度", r.m_flyStartSpeed);
            r.m_flyAcceleratedUp   = EditorGUILayout.FloatField("上升时的加速度", r.m_flyAcceleratedUp);
            r.m_flyAcceleratedDown = EditorGUILayout.FloatField("下落时的加速度", r.m_flyAcceleratedDown);
            r.m_flySpeedUpLimit    = EditorGUILayout.FloatField("速度上限", r.m_flySpeedUpLimit);
            r.m_flySpeeDownLimit   = EditorGUILayout.FloatField("速度下限", r.m_flySpeeDownLimit);
            EditorGUILayout.Space();
            r.m_groundDuration = EditorGUILayout.FloatField("倒地时间", r.m_groundDuration);
            EditorGUILayout.Space();


            Animation ani = r.transform.Find("model").GetComponent <Animation>();
            if (ani == null)
            {
                EditorGUILayout.LabelField("找不到model的Animation,不能设置动作");
                return;
            }
            string[] aniNames = ani.GetNames();
            if (aniNames == null || aniNames.Length == 0)
            {
                EditorGUILayout.LabelField("Animation没有动作");
                return;
            }

            DrawAtk("Num4攻击键", r, r.m_num4Atk, ani, aniNames);
            DrawAtk("Num5攻击键", r, r.m_num5Atk, ani, aniNames);
            DrawAtk("Num6攻击键", r, r.m_num6Atk, ani, aniNames);
        }


        if (EditorGUI.EndChangeCheck())
        {
            //Debuger.Log("修改");
            EditorUtil.SetDirty(r);
        }
    }
    /// <summary>
    /// Creates a control useful for assigning area values.
    /// </summary>
    /// <param name="label">The default label for the control.</param>
    /// <returns></returns>
    public static AreaGUIControl CreateAreaControl(string label)
    {
        CAINavEditorSettings settings = EditorUtil.GetGlobalAsset <CAINavEditorSettings>();

        return(new AreaGUIControl(label, (string[])settings.areaNames.Clone()));
    }
Exemple #21
0
    public void DrawAtk(string title, SimpleRole r, SimpleRole.AttackCxt c, Animation ani, string[] aniNames)
    {
        if (EditorUtil.DrawHeader(string.Format("{0}:{1}", title, c.aniName)))
        {
            using (new AutoContent())
            {
                int idxOld = Array.IndexOf(aniNames, c.aniName);
                if (idxOld == -1 && !string.IsNullOrEmpty(c.aniName))
                {
                    c.aniName = "";
                }

                int idx = UnityEditor.EditorGUILayout.Popup("动作名", idxOld, aniNames);
                if (idx != idxOld)
                {
                    c.aniName = aniNames[idx];
                }

                AnimationState aniSt = ani[c.aniName];
                if (aniSt == null)
                {
                    EditorGUILayout.LabelField("无动作");
                    return;
                }
                c.wrapMode = (WrapMode)EditorGUILayout.EnumPopup("循环模式", c.wrapMode);

                //不用clamp,强制切到ClampForever
                if (c.wrapMode == WrapMode.Clamp)
                {
                    c.wrapMode = WrapMode.ClampForever;
                }

                //持续时间
                if (c.wrapMode == WrapMode.Loop || c.wrapMode == WrapMode.ClampForever || c.wrapMode == WrapMode.PingPong)
                {
                    c.duration = EditorGUILayout.FloatField("持续时间", c.duration);
                }
                else
                {
                    if (c.duration > 0)
                    {
                        c.duration = 0;
                    }
                }

                //旋转
                c.canRotate = EditorGUILayout.Toggle("可旋转", c.canRotate);
                if (c.canRotate)
                {
                    c.rotateSpeed = EditorGUILayout.FloatField("旋转速度", c.rotateSpeed);
                }

                //移动
                c.canMove = EditorGUILayout.Toggle("可移动", c.canMove);
                if (c.canMove)
                {
                    c.moveSpeed = EditorGUILayout.FloatField("移动速度", c.moveSpeed);
                }
            }
        }
    }
    static void EditSettings()
    {
        CAINavEditorSettings item = EditorUtil.GetGlobalAsset <CAINavEditorSettings>();

        Selection.activeObject = item;
    }
Exemple #23
0
        public override void OnInspectorGUI()
        {
            if (_self == null)
            {
                return;
            }

            serializedObject.Update();
            int indent = EditorGUI.indentLevel;

            EditorGUIUtility.labelWidth = 160;
            EditorGUILayout.Space();
            EditorGUILayout.HelpBox("*** " + StatsMonitor.NAME + " v" + StatsMonitor.VERSION + " by Hexagon Star Softworks ***", MessageType.None);
            EditorGUILayout.HelpBox("HOW TO CHANGE AND STORE PREFERENCES:" +
                                    "\n1. Enter play mode" +
                                    "\n2. Adjust settings in this component pane" +
                                    "\n3. Right-click on script name, choose 'Copy Component'" +
                                    "\n4. Exit play mode" +
                                    "\n5. Right-click on script name, choose 'Paste Component Values'", MessageType.Info);

            /* General parameters section */
            if (EditorUtil.PropertyChanged(_mode, new GUIContent("Mode",
                                                                 "Active: (Default) The stats monitor is drawn and operates in the foreground.\n\nInactive: Disables the stats monitor completely except for hotkeys checking.\n\nPassive: Doesn't draw the stats monitor but still polls stats in the background. Useful for hidden performance monitoring.")))
            {
                _self.Mode = (Mode)_mode.enumValueIndex;
            }
            if (EditorUtil.PropertyChanged(_style, new GUIContent("Style",
                                                                  "Minimal: Displays only the FPS counter.\n\nStatsOnly: Displays only the textual stats section.\n\nStandard: (Default) Displays the textual stats section and the graph section.\n\nFull: Displays the textual stats section, the graph section, and the sysinfo section.")))
            {
                _self.Style = (Style)_style.enumValueIndex;
            }
            if (EditorUtil.PropertyChanged(_alignment, new GUIContent("Alignment",
                                                                      "Determines the position of the stats monitor.")))
            {
                _self.Alignment = (Alignment)_alignment.enumValueIndex;
            }
            if (EditorUtil.PropertyChanged(_keepAlive, new GUIContent("Keep Alive", "If checked prevents the stats monitor object from being destroyed on level (scene) load.")))
            {
                _self.KeepAlive = _keepAlive.boolValue;
            }
            if (EditorUtil.PropertyChanged(_statsUpdateInterval, new GUIContent("Stats Update Interval", "The time, in seconds at which the text displays are updated.")))
            {
                _self.StatsUpdateInterval = _statsUpdateInterval.floatValue;
            }
            if (EditorUtil.PropertyChanged(_graphUpdateInterval, new GUIContent("Graph Update Interval", "The time, in seconds at which the graph is updated.")))
            {
                _self.GraphUpdateInterval = _graphUpdateInterval.floatValue;
            }
            if (EditorUtil.PropertyChanged(_objectsCountInterval, new GUIContent("Object Count Interval", "The time, in seconds at which objects are counted.")))
            {
                _self.ObjectsCountInterval = _objectsCountInterval.floatValue;
            }

            EditorGUILayout.Space();

            if (EditorUtil.PropertyChanged(_inputEnabled, new GUIContent("Input Enabled", "You can choose to disable Stats Monitor's own hotkey- and touch input polling and instead control the API externally, for example with another input manager.")))
            {
                _self.inputEnabled = _inputEnabled.boolValue;
            }

            /* Hot keys section */
            if (EditorUtil.Foldout(_hotKeyGroupToggle, "Hot Keys"))
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField(_modKeyToggle, new GUIContent("Toggle Modifier Key", "Optional modifier key used in combination with the toggle hot key. Set this to None if you want to use the hot key without modifier key."));
                EditorGUILayout.PropertyField(_hotKeyToggle, new GUIContent("Toggle Hot Key", "The hot key used for toggling the stats monitor visibility."));
                EditorGUILayout.PropertyField(_modKeyAlignment, new GUIContent("Alignment Modifier Key", "Optional modifier key used in combination with the alignment hot key. Set this to None if you want to use the hot key without modifier key."));
                EditorGUILayout.PropertyField(_hotKeyAlignment, new GUIContent("Alignment Hot Key", "The hot key used for switching between the alignment modes (see Alignment parameter)."));
                EditorGUILayout.PropertyField(_modKeyStyle, new GUIContent("Style Modifier Key", "Optional modifier key used in combination with the style hot key. Set this to None if you want to use the hot key without modifier key."));
                EditorGUILayout.PropertyField(_hotKeyStyle, new GUIContent("Style Hot Key", "The hot key used for switching between the different styles (see Style parameter)."));
            }

            EditorGUI.indentLevel = indent;
            EditorGUILayout.Space();

            /* Touch control section */
            if (EditorUtil.Foldout(_touchControlGroupToggle, "Touch Control"))
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.PropertyField(_toggleTouchCount, new GUIContent("Toggle Touch Count", "How many fingers have to touch the display to toggle between active/inactive mode. Set to 0 to disable."));
                EditorGUILayout.PropertyField(_switchAlignmentTapCount, new GUIContent("Switch Align Tap Count", "How many taps are required to switch between alignment positions. Set to 0 to disable."));
                EditorGUILayout.PropertyField(_switchStyleTapCount, new GUIContent("Switch Style Tap Count", "How many taps are required to switch between the different layout styles. Set to 0 to disable."));
            }

            EditorGUI.indentLevel = indent;
            EditorGUILayout.Space();

            /* Look and feel section */
            if (EditorUtil.Foldout(_layoutAndStylingToggle, "Layout & Styling"))
            {
                EditorGUI.indentLevel = 1;
                if (EditorUtil.PropertyChanged(_fontFace, new GUIContent("Font", "The font used for all text fields. Leave blank to use the included font.")))
                {
                    _self.FontFace = (Font)_fontFace.objectReferenceValue;
                }
                if (EditorUtil.PropertyChanged(_fontSizeLarge, new GUIContent("Large font size", "Font size for the FPS counter.")))
                {
                    _self.FontSizeLarge = _fontSizeLarge.intValue;
                }
                if (EditorUtil.PropertyChanged(_fontSizeSmall, new GUIContent("Small font size", "Font size for all small text.")))
                {
                    _self.FontSizeSmall = _fontSizeSmall.intValue;
                }
                if (EditorUtil.PropertyChanged(_padding, new GUIContent("Padding", "The padding between the outer edges and text fields.")))
                {
                    _self.Padding = _padding.intValue;
                }
                if (EditorUtil.PropertyChanged(_spacing, new GUIContent("Spacing", "The spacing between text fields.")))
                {
                    _self.Spacing = _spacing.intValue;
                }
                if (EditorUtil.PropertyChanged(_graphHeight, new GUIContent("Graph height", "Determines the height of the graph.")))
                {
                    _self.GraphHeight = _graphHeight.intValue;
                }
                if (EditorUtil.PropertyChanged(_autoScale,
                                               new GUIContent("Autoscale", "If turned on, scale will be determined according to current screen DPI. Recommended to leave on for testing on various supported devices that have large differences in screen resolution.")))
                {
                    _self.AutoScale = _autoScale.boolValue;
                }
                GUI.enabled = !_autoScale.boolValue;
                if (EditorUtil.PropertyChanged(_scale, new GUIContent("Scale", "Allows to scale up the size of the stats monitor view by a multiplier.")))
                {
                    _self.Scale = _scale.intValue;
                }
                GUI.enabled = true;
                if (EditorUtil.PropertyChanged(_colorBGUpper, new GUIContent("BG Color Top", "The color and transparency of the background panel top.")))
                {
                    _self.ColorBgUpper = _colorBGUpper.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorBGLower, new GUIContent("BG Color Bottom", "The color and transparency of the background panel bottom.")))
                {
                    _self.ColorBgLower = _colorBGLower.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorGraphBG, new GUIContent("Graph Background Color", "The background color and transparency of the graph area.")))
                {
                    _self.ColorGraphBG = _colorGraphBG.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorFPS, new GUIContent("FPS Color", "Color used for the FPS value.")))
                {
                    _self.ColorFPS = _colorFPS.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorFPSWarning, new GUIContent("FPS Warning Color", "The FPS counter will use this color if FPS falls below the FPS warning threshold.")))
                {
                    _self.ColorFPSWarning = _colorFPSWarning.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorFPSCritical, new GUIContent("FPS Critical Color", "The FPS counter will use this color if FPS falls below the FPS critical threshold.")))
                {
                    _self.ColorFPSCritical = _colorFPSCritical.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorFPSMin, new GUIContent("FPS Min Color", "Color used for the FPS minimum value.")))
                {
                    _self.ColorFPSMin = _colorFPSMin.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorFPSMax, new GUIContent("FPS Max Color", "Color used for the FPS maximum value.")))
                {
                    _self.ColorFPSMax = _colorFPSMax.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorFPSAvg, new GUIContent("FPS Average Color", "Color used for FPS average value.")))
                {
                    _self.ColorFPSAvg = _colorFPSAvg.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorMS, new GUIContent("Milliseconds Color", "Color used for the milliseconds value.")))
                {
                    _self.ColorMS = _colorMS.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorGCBlip, new GUIContent("GC Blip Color", "Color used for garbage collection graph blip.")))
                {
                    _self.ColorGCBlip = _colorGCBlip.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorFXD, new GUIContent("Fixed Update Color", "Color used for Fixed Update 'frame'-rate.")))
                {
                    _self.ColorFxd = _colorFXD.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorObjCount, new GUIContent("Objects Count Color", "Color used for the 'currently rendered objects' / 'total render objects' / 'total game objects' values.")))
                {
                    _self.ColorObjectCount = _colorObjCount.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorMemTotal, new GUIContent("Total Memory Color", "Color used for the total memory value.")))
                {
                    _self.ColorMemTotal = _colorMemTotal.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorMemAlloc, new GUIContent("Allocated Memory Color", "Color used for the allocated memory value.")))
                {
                    _self.ColorMemAlloc = _colorMemAlloc.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorMemMono, new GUIContent("Mono Memory Color", "Color used for the mono memory value.")))
                {
                    _self.ColorMemMono = _colorMemMono.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorSysInfoOdd, new GUIContent("System Info Odd Color", "Color used for odd sysinfo rows.")))
                {
                    _self.ColorSysInfoOdd = _colorSysInfoOdd.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorSysInfoEven, new GUIContent("System Info Even Color", "Color used for even sysinfo rows.")))
                {
                    _self.ColorSysInfoEven = _colorSysInfoEven.colorValue;
                }
                if (EditorUtil.PropertyChanged(_colorOutline, new GUIContent("Outline Color", "Color used for text and graph outline. Setting alpha to 0 will remove the effect components.")))
                {
                    _self.ColorOutline = _colorOutline.colorValue;
                }
            }

            EditorGUI.indentLevel = indent;
            EditorGUILayout.Space();

            /* FPS-Specific section */
            if (EditorUtil.Foldout(_fpsGroupToggle, "FPS Specific"))
            {
                EditorGUI.indentLevel = 1;
                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                if (EditorUtil.PropertyChanged(_throttleFrameRate, new GUIContent("Throttle FPS", "Enables or disables FPS throttling. This allows to see how the game performs under a specific frame rate. Does not guarantee selected frame rate. Set this to -1 to render as fast as possible in current conditions.\n\nIMPORTANT: this option disables VSync while enabled!")))
                {
                    _self.ThrottleFrameRate = _throttleFrameRate.boolValue;
                }
                if (EditorUtil.PropertyChanged(_throttledFrameRate, new GUIContent()))
                {
                    _self.ThrottledFrameRate = _throttledFrameRate.intValue;
                }
                EditorGUILayout.EndHorizontal();
                if (EditorUtil.PropertyChanged(_avgSamples, new GUIContent("Average FPS Samples", "The amount of samples collected to calculate the average FPS value from. Setting this to 0 will result in an average FPS value calculated from all samples since startup or level load.")))
                {
                    _self.AverageSamples = _avgSamples.intValue;
                }
                if (EditorUtil.PropertyChanged(_warningThreshold, new GUIContent("FPS Warning Threshold", "The threshold below which the FPS will be marked with warning color.")))
                {
                    _self.WarningThreshold = _warningThreshold.intValue;
                }
                if (EditorUtil.PropertyChanged(_criticalThreshold, new GUIContent("FPS Critical Threshold", "The threshold below which the FPS will be marked with critical color.")))
                {
                    _self.CriticalThreshold = _criticalThreshold.intValue;
                }
            }

            EditorGUILayout.Space();
            serializedObject.ApplyModifiedProperties();
        }
    /// <summary>
    /// 创建数据表对应的具体数据类
    /// </summary>
    /// <param name="dataName"></param>
    /// <param name="data"></param>
    public static void CreatDataCSharpFile(string dataName, DataTable data)
    {
        if (dataName.Contains("/"))
        {
            string[] tmp = dataName.Split('/');
            dataName = tmp[tmp.Length - 1];
        }

        string className = dataName + "Generate";
        string content   = "";

        content += "using System;\n";
        content += "using UnityEngine;\n\n";

        content += @"//" + className + "类\n";
        content += @"//该类自动生成请勿修改,以避免不必要的损失";
        content += "\n";

        content += "public class " + className + " : DataGenerateBase \n";
        content += "{\n";

        content += "\tpublic string m_key;\n";

        //type
        List <string> type = new List <string>(data.m_tableTypes.Keys);

        //Debug.Log("type count: " + type.Count);

        if (type.Count > 0)
        {
            for (int i = 1; i < data.TableKeys.Count; i++)
            {
                string key      = data.TableKeys[i];
                string enumType = null;

                if (data.m_tableEnumTypes.ContainsKey(key))
                {
                    enumType = data.m_tableEnumTypes[key];
                }

                string note = ";";

                if (data.m_noteValue.ContainsKey(key))
                {
                    note = @"; //" + data.m_noteValue[key];
                }

                content += "\t";

                if (data.m_tableTypes.ContainsKey(key))
                {
                    //访问类型 + 字段类型  + 字段名
                    content += "public " + OutPutFieldName(data.m_tableTypes[key], enumType) + " m_" + key + note;
                }
                //默认字符类型
                else
                {
                    //访问类型 + 字符串类型 + 字段名
                    content += "public " + "string" + " m_" + key + note;
                }

                content += "\n";
            }
        }

        content += "\n";

        content += "\tpublic override void LoadData(string key) \n";
        content += "\t{\n";
        content += "\t\tDataTable table =  DataManager.GetData(\"" + dataName + "\");\n\n";
        content += "\t\tif (!table.ContainsKey(key))\n";
        content += "\t\t{\n";
        content += "\t\t\tthrow new Exception(\"" + className + " LoadData Exception Not Fond key ->\" + key + \"<-\");\n";
        content += "\t\t}\n";
        content += "\n";
        content += "\t\tSingleData data = table[key];\n\n";

        content += "\t\tm_key = key;\n";

        if (type.Count > 0)
        {
            for (int i = 1; i < data.TableKeys.Count; i++)
            {
                string key = data.TableKeys[i];

                content += "\t\t";

                string enumType = null;

                if (data.m_tableEnumTypes.ContainsKey(key))
                {
                    enumType = data.m_tableEnumTypes[key];
                }

                if (data.m_tableTypes.ContainsKey(key))
                {
                    content += "m_" + key + " = data." + OutPutFieldFunction(data.m_tableTypes[key], enumType) + "(\"" + key + "\")";
                }
                //默认字符类型
                else
                {
                    content += "m_" + key + " = data." + OutPutFieldFunction(FieldType.String, enumType) + "(\"" + key + "\")";
                    Debug.LogWarning("字段 " + key + "没有配置类型!");
                }

                content += ";\n";
            }
        }

        content += "\t}\n";
        content += "}\n";

        string SavePath = Application.dataPath + "/Script/DataClassGenerate/" + className + ".cs";

        EditorUtil.WriteStringByFile(SavePath, content.ToString());
    }
Exemple #25
0
        static void MenuItem()
        {
            List <GameObject> graphObjects = EditorUtil.CreateGameObject("Graph", typeof(MBGraph));

            Selection.objects = graphObjects.ToArray();
        }