Ejemplo n.º 1
0
    static void CreateWindow()
    {
        Rect       wr     = new Rect(0, 0, 500, 500);
        MenuEditor window = EditorWindow.CreateWindow <MenuEditor>("大窗口来了");

        window.Show();
    }
        internal static bool ShowGraphEditWindow(string path)
        {
            var guid      = AssetDatabase.AssetPathToGUID(path);
            var extension = Path.GetExtension(path);

            if (string.IsNullOrEmpty(extension))
            {
                return(false);
            }
            // Path.GetExtension returns the extension prefixed with ".", so we remove it. We force lower case such that
            // the comparison will be case-insensitive.
            extension = extension.Substring(1).ToLowerInvariant();
            if (extension != ShaderGraphImporter.Extension && extension != ShaderSubGraphImporter.Extension)
            {
                return(false);
            }

            foreach (var w in Resources.FindObjectsOfTypeAll <MaterialGraphEditWindow>())
            {
                if (w.selectedGuid == guid)
                {
                    w.Focus();
                    return(true);
                }
            }

            var window = EditorWindow.CreateWindow <MaterialGraphEditWindow>(typeof(MaterialGraphEditWindow), typeof(SceneView));

            window.Initialize(guid);
            window.Focus();
            return(true);
        }
Ejemplo n.º 3
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        //base.OnGUI( position , property , label );
        EditorGUI.BeginProperty(position, label, property);

        EditorGUI.LabelField(position, label);

        if (paleting == 0)
        {
            Color color = property.colorValue;
            color = EditorGUI.ColorField(new Rect(position.x + position.width / 2.5f, position.y, 150, position.height), GUIContent.none, color, false, true, false);
            property.colorValue = color;
        }
        else if (paleting == 2)
        {
            property.colorValue = PlayerData.GetCacheColor(); paleting = 0;
        }

        if (GUI.Button(new Rect(position.x + position.width / 1.25f, position.y, 75, position.height), new GUIContent("Palettes")))
        {
            //EditorWindow.GetWindow<ColorPalette_Editor>( "Color Palette" );
            ColorPalette_Editor window = EditorWindow.CreateWindow <ColorPalette_Editor>("Color Palette");
            window.selecting = true;
            window.inspector = this;
            paleting         = 1;
        }

        EditorGUI.EndProperty( );

        //if (GUILayout.Button( "" , GUILayout.Width( 10 ) , GUILayout.Height( 10 ) )) { EditorWindow.GetWindow<ColorPalette_Editor>( "Color Palette" ); }
    }
Ejemplo n.º 4
0
        private static void OpenScrubberEditorWindow <T>(Object scrubData) where T : ScrubberEditorWindow
        {
            T wnd = EditorWindow.CreateWindow <T>(new Type[] { typeof(T) });

            wnd.titleContent     = new UnityEngine.GUIContent(scrubData.name);
            wnd.SerializedObject = new SerializedObject(scrubData);
        }
Ejemplo n.º 5
0
        void OnDestroy()
        {
            // we are closing the shadergraph window
            MaterialGraphEditWindow newWindow = null;

            if (!PromptSaveIfDirtyOnQuit())
            {
                // user does not want to close the window.
                // we can't stop the close from this code path though..
                // all we can do is open a new window and transfer our data to the new one to avoid losing it
                // newWin = Instantiate<MaterialGraphEditWindow>(this);
                newWindow = EditorWindow.CreateWindow <MaterialGraphEditWindow>(typeof(MaterialGraphEditWindow), typeof(SceneView));
                newWindow.Initialize(this);
            }
            else
            {
                // the window is closing for good.. cleanup undo history for the graph object
                Undo.ClearUndo(graphObject);
            }

            graphObject     = null;
            graphEditorView = null;

            // show new window if we have one
            if (newWindow != null)
            {
                newWindow.Show();
                newWindow.Focus();
            }
        }
Ejemplo n.º 6
0
    static void OpenWindow()
    {
        Rect            rectangle     = new Rect((Screen.width - _winWidth) * 0.5f, (Screen.height - _winHeight) * 0.5f, _winWidth, _winHeight);
        TesseractOCrWnd aspriseOcrWnd = EditorWindow.CreateWindow <TesseractOCrWnd>("TesseractOCrWnd");

        aspriseOcrWnd.position = rectangle;
        aspriseOcrWnd.Init();
    }
Ejemplo n.º 7
0
        static void Init()
        {
            var window = EditorWindow.CreateWindow <RedisWindow>();

            window.titleContent = new GUIContent("GUI Redis");

            //EditorWindow.GetWindow(typeof(RedisWindow), false, "GUI Redis");
        }
Ejemplo n.º 8
0
        internal static EditorWindow OpenProfilerWindow()
        {
            var profilerWindow = EditorWindow.CreateWindow <ProfilerWindow>();

            SwitchToCPUView(profilerWindow);
            profilerWindow.Show();
            return(profilerWindow);
        }
Ejemplo n.º 9
0
        public static void CreateWindow()
        {
            var window = EditorWindow.CreateWindow <OctahedralTextureEditor>();

            window.Show();
            window.mouseAction.zoom        = 10.0f;
            window.mouseAction.rotateEuler = Quaternion.LookRotation(new Vector3(0f, -0.5f, 0.5f).normalized).eulerAngles;
        }
Ejemplo n.º 10
0
        public static IEnumerator ImportDTURoutine(string path, Action <DTU> dtuOut, float progressLimit)
        {
            Debug.Log("ImportDTU for " + path);

            FoldAll();

            ImportEventRecord record = new ImportEventRecord();

            EventQueue.Enqueue(record);

            var dtu = DTUConverter.ParseDTUFile(path);

            dtuOut(dtu);

            var dtuObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path);

            record.AddToken("Imported DTU file: " + path);
            record.AddToken(dtuObject.name, dtuObject, ENDLINE);

            //UnityEngine.Debug.Log("DTU: " + dtu.AssetName + " contains: " + dtu.Materials.Count + " materials");


            record.AddToken("Generated materials: ");
            float progressIncrement = (progressLimit - Daz3DBridge.Progress) / dtu.Materials.Count;

            for (int i = 0; i < dtu.Materials.Count; i++)
            {
                var dtuMat   = dtu.Materials[i];
                var material = dtu.ConvertToUnity(dtuMat);
                _map.AddMaterial(material);

                record.AddToken(material.name, material);

                Daz3DBridge.Progress = Mathf.MoveTowards(Daz3DBridge.Progress, progressLimit, progressIncrement);

                yield return(new WaitForEndOfFrame());
            }
            record.AddToken(" based on DTU file.", null, ENDLINE);


            Daz3DBridge bridge = EditorWindow.GetWindow(typeof(Daz3DBridge)) as Daz3DBridge;

            if (bridge == null)
            {
                var consoleType = Type.GetType("ConsoleWindow,UnityEditor.dll");
                bridge = EditorWindow.CreateWindow <Daz3DBridge>(new[] { consoleType });
            }

            bridge?.Focus();

            //just a safeguard to keep the history data at a managable size (100 records)
            while (EventQueue.Count > 100)
            {
                EventQueue.Dequeue();
            }

            yield break;
        }
Ejemplo n.º 11
0
        public static ViewWindow Show(IView view, Rect rect)
        {
            var win = EditorWindow.CreateWindow <ViewWindow>(view.title);

            win.position = rect;
            win.view     = view;
            win.Show();
            return(win);
        }
        internal static EditorWindow OpenProfilerWindow()
        {
#if UNITY_2019_3_OR_NEWER
            var profilerWindow = EditorWindow.CreateWindow <ProfilerWindow>();
#else
            var profilerWindow = EditorWindow.GetWindow(m_ProfilerWindowType);
#endif
            SwitchToCPUView(profilerWindow);
            profilerWindow.Show();
            return(profilerWindow);
        }
Ejemplo n.º 13
0
        public static RowEditorWnd Create(string title, EditorWindow parent, LuaReflect luaReflect, string excelPath)
        {
            Rect rect = new Rect(parent.position.x + parent.position.width + 20, parent.position.y, parent.position.width, parent.position.height);

            EditorWindow.FocusWindowIfItsOpen(typeof(RowEditorWnd));
            RowEditorWnd wnd = EditorWindow.CreateWindow <RowEditorWnd>(title);

            wnd.position = rect;
            wnd.ShowWnd(parent, luaReflect, excelPath);
            return(wnd);
        }
Ejemplo n.º 14
0
    public static VerTexturaSola Mostrar(Texture2D txt, bool autoDestruir = true, bool instanciar = false)
    {
        var win = instanciar ? EditorWindow.CreateWindow <VerTexturaSola>() : GetWindow <VerTexturaSola>(true);

        if (win.textura && win.autoDestruir)
        {
            DestroyImmediate(win.textura);
        }
        win.textura      = txt;
        win.autoDestruir = autoDestruir;
        return(win);
    }
Ejemplo n.º 15
0
        public void OpenGraphWindow(Graph graph)
        {
            GraphEditor window = null;

            int _id = graph.GetInstanceID();

            // check if other graph windows are already open
            // happens if user has closed unity and left some graph windows open
            // then we have to add them to the graphwindows list again.
            if (graphWindows.Count == 0 || graphWindows == null)
            {
                GraphEditor[] _w = Resources.FindObjectsOfTypeAll <GraphEditor>();

                if (_w.Length > 0)
                {
                    //Debug.Log(_w.Length);

                    for (int w = 0; w < _w.Length; w++)
                    {
                        graphWindows.Add(new GraphWindows(_w[w].rootGraph.GetInstanceID(), _w[w]));
                    }
                }
            }

            for (int i = 0; i < graphWindows.Count; i++)
            {
                if (graphWindows[i].id == _id)
                {
                    window = graphWindows[i].graphEditor;
                }
            }

            if (window != null)
            {
                window.Init(window, graph);
                window.Focus();
            }
            else
            {
                //window = CreateInstance<GraphEditor>();
                window = (GraphEditor)EditorWindow.CreateWindow <GraphEditor>(typeof(GraphEditor));
                graphWindows.Add(new GraphWindows(graph.GetInstanceID(), window));
                window.Init(window, graph);
            }

            // Check if graph needs to be updated
            GraphUpdater.UpdateGraph(graph);

            EditorUtility.SetDirty(this);
        }
Ejemplo n.º 16
0
        public static ListEditorWnd Create(string title, EditorWindow parent, LuaReflect luaReflect, ExcelColHeader header, string vid)
        {
            Rect          rect = new Rect(parent.position.x + parent.position.width + 20, parent.position.y, parent.position.width, parent.position.height);
            ListEditorWnd wnd  = EditorWindow.CreateWindow <ListEditorWnd>(title);

            wnd.position = rect;
            ExcelEditor excelEditor = new ExcelEditor(header.linkEditorUrl);

            wnd.ShowWnd(excelEditor);
            wnd.SetShowRows(excelEditor.GetRowIndexes(header.linkEditorField, vid), true);
            wnd.header     = header;
            wnd.luaReflect = luaReflect;
            return(wnd);
        }
Ejemplo n.º 17
0
        public static void ImportDTU(string path)
        {
            Debug.Log("ImportDTU for " + path);

            FoldAll();

            ImportEventRecord record = new ImportEventRecord();

            EventQueue.Enqueue(record);

            var dtu = DTUConverter.ParseDTUFile(path);

            var dtuObject = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(path);

            record.AddToken("Imported DTU file: " + path);
            record.AddToken(dtuObject.name, dtuObject, ENDLINE);

            //UnityEngine.Debug.Log("DTU: " + dtu.AssetName + " contains: " + dtu.Materials.Count + " materials");

            record.AddToken("Generated materials: ");
            foreach (var dtuMat in dtu.Materials)
            {
                var material = dtu.ConvertToUnity(dtuMat);
                _map.AddMaterial(material);

                record.AddToken(material.name, material);
            }
            record.AddToken(" based on DTU file.", null, ENDLINE);


            Daz3DBridge bridge = EditorWindow.GetWindow(typeof(Daz3DBridge)) as Daz3DBridge;

            if (bridge == null)
            {
                var consoleType = Type.GetType("ConsoleWindow,UnityEditor.dll");
                bridge = EditorWindow.CreateWindow <Daz3DBridge>(new[] { consoleType });
            }

            bridge?.Focus();

            //just a safeguard to keep the history data at a managable size (100 records)
            while (EventQueue.Count > 100)
            {
                EventQueue.Dequeue();
            }
        }
        public static bool OpenEditorWindow(string assetPath)
        {
            var guid      = AssetDatabase.AssetPathToGUID(assetPath);
            var extension = Path.GetExtension(assetPath);

            if (string.IsNullOrEmpty(extension))
            {
                return(false);
            }

            extension = extension.Substring(1).ToLowerInvariant();
            if (extension != DlogGraphImporter.Extension)
            {
                return(false);
            }

            var dlogObject = DlogUtility.LoadGraphAtPath(assetPath);

            if (string.IsNullOrEmpty(dlogObject.AssetGuid))
            {
                dlogObject.RecalculateAssetGuid(assetPath);
                DlogUtility.SaveGraph(dlogObject, false);
            }

            foreach (var activeWindow in Resources.FindObjectsOfTypeAll <DlogEditorWindow>())
            {
                if (activeWindow.SelectedAssetGuid != guid)
                {
                    continue;
                }

                // TODO: Ask user if they want to replace the current window (maybe ask to save before opening with cancel button)
                activeWindow.SetDlogObject(dlogObject);
                activeWindow.BuildWindow();
                activeWindow.Focus();
                return(true);
            }

            var window = EditorWindow.CreateWindow <DlogEditorWindow>(typeof(DlogEditorWindow), typeof(SceneView));

            window.titleContent = EditorGUIUtility.TrTextContentWithIcon(guid, Resources.Load <Texture2D>(ResourcesUtility.IconSmall));
            window.SetDlogObject(dlogObject);
            window.BuildWindow();
            window.Focus();
            return(true);
        }
Ejemplo n.º 19
0
        public new static SelectWnd Create(string title, EditorWindow parent, LuaReflect luaReflect, string excelPath)
        {
            Rect      rect = new Rect(parent.position.x + parent.position.width + 20, parent.position.y, parent.position.width, parent.position.height);
            SelectWnd wnd  = EditorWindow.CreateWindow <SelectWnd>(title);

            wnd.position = rect;
            ExcelEditor excelEditor = new ExcelEditor(excelPath);

            wnd.ShowWnd(excelEditor);
            int[] showRows = new int[excelEditor.dataTable.Rows.Count - 2];
            for (int i = 0; i < showRows.Length; i++)
            {
                showRows[i] = i + 2;
            }
            wnd.SetShowRows(showRows, false);
            wnd.luaReflect = luaReflect;
            return(wnd);
        }
Ejemplo n.º 20
0
 public static T CreateNewWindow <T>(System.Object handle = null) where T : MDIEditorWindow
 {
     #if UNITY_2019_2_OR_NEWER
     T window = EditorWindow.CreateWindow <T>();
     #else
     T window = EditorWindow.CreateInstance <T>();
     #endif
     if (handle != null)
     {
         window.m_Handle = EWSerializationObject.CreateInstance(handle);
     }
     else
     {
         window.m_Handle = null;
     }
     window.Clear();
     window.Init();
     window.m_IsInitialized = true;
     return(window);
 }
Ejemplo n.º 21
0
        public static EditorMessageBox Show(string title, string content, string button1Text,
                                            Action onButton1Callback = null, string button2Text = null, Action onButton2Callback = null)
        {
            EditorMessageBox editorMessageBox = EditorWindow.CreateWindow <EditorMessageBox>();

            editorMessageBox.minSize      = new Vector2(EditorMessageBoxConst.Width, EditorMessageBoxConst.Height);
            editorMessageBox.maxSize      = editorMessageBox.minSize;
            editorMessageBox.messageTitle = title;
            editorMessageBox.content      = content;

            editorMessageBox.button1Text       = button1Text;
            editorMessageBox.onButton1Callback = onButton1Callback;

            editorMessageBox.button2Text       = button2Text;
            editorMessageBox.onButton2Callback = onButton2Callback;


            editorMessageBox.Show();

            return(editorMessageBox);
        }
Ejemplo n.º 22
0
        public static MixtureGraphWindow Open(MixtureGraph graph)
        {
            // Focus the window if the graph is already opened
            var mixtureWindows = Resources.FindObjectsOfTypeAll <MixtureGraphWindow>();

            foreach (var mixtureWindow in mixtureWindows)
            {
                if (mixtureWindow.graph == graph)
                {
                    mixtureWindow.Show();
                    mixtureWindow.Focus();
                    return(mixtureWindow);
                }
            }

            var graphWindow = EditorWindow.CreateWindow <MixtureGraphWindow>();

            graphWindow.Show();
            graphWindow.Focus();

            graphWindow.InitializeGraph(graph);

            return(graphWindow);
        }
Ejemplo n.º 23
0
        public static void Open()
        {
            var window = EditorWindow.CreateWindow <ScreenShotWindow>();

            window.Show();
        }
Ejemplo n.º 24
0
    public static void CreateEditor()
    {
        BrokenSystemEditor editor = EditorWindow.CreateWindow <BrokenSystemEditor>();

        editor.Show();
    }
Ejemplo n.º 25
0
 static void Open()
 {
     var window = EditorWindow.CreateWindow <BoltExplorer>();
 }
Ejemplo n.º 26
0
 private static void ShowWindow()
 {
     EditorWindow.CreateWindow <MTMeshEditor>();
 }
Ejemplo n.º 27
0
 private static void OpenSplitAnimationEditor()
 {
     EditorWindow.CreateWindow <SplitAnimationClipEditor>().Show();
 }
Ejemplo n.º 28
0
 static void OpenWindow()
 {
     var window = EditorWindow.CreateWindow <EnvironmentBUilder>();
 }
Ejemplo n.º 29
0
        public static void Open()
        {
            var window = EditorWindow.CreateWindow <SubComponentSummaryWindow>();

            window.Show();
        }
    IEnumerator GenerateScreenshots()
    {
        var          t        = Resources.Load <Texture>("DocumentationGraph");//.FirstOrDefault(g => { Debug.Log(g); return g is MixtureGraph;}) as MixtureGraph;
        MixtureGraph docGraph = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(t)).FirstOrDefault(g => g is MixtureGraph) as MixtureGraph;

        // Setup doc graph properties:
        docGraph.scale    = Vector3.one;
        docGraph.position = new Vector3(0, toolbarHeight, 0);
        docGraph.nodes.RemoveAll(n => !(n is OutputNode));

        // yield return null;

        var window = EditorWindow.CreateWindow <MixtureGraphWindow>();

        window.Show();
        window.Focus();

        window.minSize = new Vector2(1024, 1024);
        window.maxSize = new Vector2(1024, 1024);

        var nodeViews = new List <BaseNodeView>();

        foreach (var node in NodeProvider.GetNodeMenuEntries(docGraph))
        {
            if (node.path.Contains("Experimental"))
            {
                continue;
            }

            // Skip non-mixture nodes:
            if (!node.type.FullName.Contains("Mixture"))
            {
                continue;
            }

            // We'll suport loops after
            if (node.type == typeof(ForeachStart) || node.type == typeof(ForStart))
            {
                continue;
            }

            window.InitializeGraph(docGraph);
            var graphView = window.view;
            var newNode   = BaseNode.CreateFromType(node.type, new Vector2(0, toolbarHeight));
            var nodeView  = graphView.AddNode(newNode);
            nodeViews.Add(nodeView);
            graphView.Add(nodeView);
            SetupNodeIfNeeded(nodeView);

            graphView.MarkDirtyRepaint();
            graphView.UpdateViewTransform(new Vector3(0, 0, 0), Vector3.one * graphView.scale);
            graphView.Focus();

            MixtureGraphProcessor.RunOnce(docGraph);

            yield return(new WaitForEndOfFrame());

            if (window == null)
            {
                yield break;
            }

            TakeAndSaveNodeScreenshot(window, nodeView);

            GenerateNodeMarkdownDoc(nodeView);

            graphView.RemoveNodeView(nodeView);
            graphView.graph.RemoveNode(nodeView.nodeTarget);

            graphView.MarkDirtyRepaint();
            yield return(new WaitForEndOfFrame());
        }

        nodeViews.Sort((n1, n2) => n1.nodeTarget.name.CompareTo(n2.nodeTarget.name));

        GenerateNodeIndexFiles(nodeViews);

        foreach (var node in docGraph.nodes.ToList())
        {
            if (!(node is OutputNode))
            {
                docGraph.RemoveNode(node);
            }
        }

        window.Close();
    }