示例#1
0
        public void     OnGUI(Rect r, int i, float minY, float maxY, Project master = null)
        {
            if (this.root == null || (master == null && this.watcher == null))
            {
                return;
            }

            GUI.Box(r, GUIContent.none, GeneralStyles.Toolbar);
            float w = r.width;

            r.height = 16F;

            Utility.content.text = master == null ? "[Master]" : "[Slave " + i + "]";
            r.width = GUI.skin.label.CalcSize(Utility.content).x;
            GUI.Label(r, Utility.content);
            r.x += r.width;

            r.width = w - r.width;
            if (master != null)
            {
                r.width -= 75F;
            }
            NGEditorGUILayout.ElasticLabel(r, this.root.path, '/');

            using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton))
            {
                EditorGUI.BeginDisabledGroup(this.root.CanDisplay == false);
                {
                    if (master != null)
                    {
                        r.x    += r.width;
                        r.width = 75F;
                        if (GUI.Button(r, "Sync", GeneralStyles.ToolbarButton) == true)
                        {
                            this.SyncAll(master);
                        }
                    }
                }
                EditorGUI.EndDisabledGroup();
            }

            r.x     = 0F;
            r.y    += r.height;
            r.width = w;

            if (master != null)
            {
                this.root.OnGUI(r, minY, maxY, master.root);
            }
            else
            {
                this.root.OnGUI(r, minY, maxY, null);
            }
        }
示例#2
0
        private void    PreviewPath(Rect r, string fullPath)
        {
            bool exists = Directory.Exists(fullPath);

            if (exists == false)
            {
                r.xMin += 34F;
            }
            else
            {
                r.xMin += 16F;
            }

            Color restore = GeneralStyles.SmallLabel.normal.textColor;

            if (exists == false)
            {
                GeneralStyles.SmallLabel.normal.textColor = Color.yellow;
            }

            NGEditorGUILayout.ElasticLabel(r, fullPath, '/', GeneralStyles.SmallLabel);

            GeneralStyles.SmallLabel.normal.textColor = restore;

            r.width = 16F;

            if (exists == false)
            {
                r.x -= 16F;

                GUI.DrawTexture(r, UtilityResources.WarningIcon);
            }

            r.y -= 5F;
            r.x  = 5F;

            GUI.Label(r, "↳", GeneralStyles.Title1);
        }
示例#3
0
        private void    DrawBuildSceneRow(Rect r, EditorBuildSettingsScene scene, int i)
        {
            float w = r.width - 4F;

            if (Event.current.type == EventType.Repaint && r.Contains(Event.current.mousePosition) == true)
            {
                if (DragAndDrop.visualMode == DragAndDropVisualMode.Move)
                {
                    float h = r.height;
                    r.height = 1F;
                    EditorGUI.DrawRect(r, Color.green);
                    r.height = h;
                }
            }
            else if (Event.current.type == EventType.DragUpdated && r.Contains(Event.current.mousePosition) == true)
            {
                bool one = false;

                for (int j = 0; j < DragAndDrop.paths.Length; j++)
                {
                    if (DragAndDrop.paths[j].EndsWith(".unity", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        one = true;
                        break;
                    }
                }

                if (one == true)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                }
                else
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                }
            }
            else if (Event.current.type == EventType.DragPerform && r.Contains(Event.current.mousePosition) == true)
            {
                if (DragAndDrop.paths.Length > 0)
                {
                    DragAndDrop.AcceptDrag();

                    List <EditorBuildSettingsScene> scenes = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);

                    for (int j = 0; j < DragAndDrop.paths.Length; j++)
                    {
                        if (DragAndDrop.paths[j].EndsWith(".unity", StringComparison.OrdinalIgnoreCase) == true)
                        {
                            scenes.Insert(i++, new EditorBuildSettingsScene(DragAndDrop.paths[j], true));
                        }
                    }

                    EditorBuildSettings.scenes = scenes.ToArray();

                    Event.current.Use();
                }
            }

            EditorGUI.BeginDisabledGroup(!File.Exists(scene.path));
            {
                r.x    += 4F;
                r.width = 20F;
                EditorGUI.BeginChangeCheck();
                bool enabled = GUI.Toggle(r, scene.enabled, string.Empty);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes.Clone() as EditorBuildSettingsScene[];

                    scenes[i] = new EditorBuildSettingsScene(scene.path, enabled);
                    EditorBuildSettings.scenes = scenes;
                }

                string path;

                if (this.shrinkedPaths.TryGetValue(scene.path, out path) == false)
                {
                    int start  = 0;
                    int length = scene.path.Length;

                    if (scene.path.StartsWith("Assets/") == true)
                    {
                        start   = "Assets/".Length;
                        length -= start;
                    }

                    if (scene.path.EndsWith(".unity", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        length -= ".unity".Length;
                    }

                    path = scene.path.Substring(start, length);
                    this.shrinkedPaths.Add(scene.path, path);
                }

                r.x += r.width;
                if (scene.enabled == true)
                {
                    Utility.content.text = this.enabledScenesCounter.ToCachedString();
                    float indexWidth = GUI.skin.label.CalcSize(Utility.content).x;
                    r.width = w - r.x - indexWidth;
                    NGEditorGUILayout.ElasticLabel(r, path, '/');

                    r.x    += r.width;
                    r.width = indexWidth;
                    GUI.Label(r, this.enabledScenesCounter.ToCachedString());
                    ++this.enabledScenesCounter;
                }
                else
                {
                    r.width = w - r.x;
                    GUI.Label(r, path);
                }
            }
            EditorGUI.EndDisabledGroup();
        }