Ejemplo n.º 1
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            importedShaderPaths.Clear();

            foreach (string str in importedAssets)
            {
                if (scriptImportedAssetPaths.Contains(str))
                {
                    scriptImportedAssetPaths.Remove(str);
                    continue;
                }
                //if (allShaderPaths.Contains(str)) continue;
                //else allShaderPaths.Add(str);
                Object asset = AssetDatabase.LoadAssetAtPath <Object>(str);
                if (asset != null && asset.GetType() == typeof(Shader))
                {
                    Shader shader = AssetDatabase.LoadAssetAtPath <Shader>(str);
                    importedShaderPaths.Add(str);
                    deleteQueueShaders(shader, str);
                }
                else if (asset != null && str.ToLower().Contains("ThryEditor"))
                {
                    ThryEditor.reload();
                }
            }
            if (importedShaderPaths.Count == 0)
            {
                return;
            }

            if (ignore)
            {
                return;
            }
            if (!Config.Get().showImportPopup)
            {
                return;
            }
            EditorWindow window = UnityHelper.FindEditorWindow(typeof(ShaderImportFixerGui));

            if (window == null)
            {
                window = EditorWindow.CreateInstance <ShaderImportFixerGui>();
            }
            window.Show();
        }
Ejemplo n.º 2
0
        public static void DisplaySearchableCustomMenu(
            Rect position,
            string[] options,
            Func <int, bool> checkEnabled,
            int selected,
            EditorUtility.SelectMenuItemFunction callback,
            object userData,
            float windowHeight = 300)
        {
            var window = EditorWindow.CreateInstance <SearchablePopupWindow>();

            window.Init(options, checkEnabled, selected, callback, userData);

            position.position = GUIUtility.GUIToScreenPoint(position.position);
            position.height  += 1;
            window.ShowAsDropDown(position, new Vector2(position.width, windowHeight));
        }
Ejemplo n.º 3
0
        private void AddPropertyDialog(BaseTemplate parent)
        {
            _parentTemplate = parent;

            AddPropertyDialog dialog = EditorWindow.CreateInstance <AddPropertyDialog>();

            dialog.onAddClick += OnAddPropertyClick;
            dialog.onClose    += OnPropertyDlgClose;

#if UNITY_5 && !UNITY_5_0 || UNITY_2017
            dialog.titleContent.text = "Add Property";
#else
            dialog.title = "Add Property";
#endif

            dialog.ShowAuxWindow();
        }
Ejemplo n.º 4
0
        public static void Show(Rect r, SerializedProperty prop)
        {
            if (instance == null)
            {
                instance = (CustomTextEditorWindow)EditorWindow.CreateInstance <CustomTextEditorWindow>();
            }

            //instance.ShowAsDropDown(r, r.size);
            //instance.ShowUtility();
            r.y -= 16;
            if (r.height < 300)
            {
                r.height = 360;
            }
            r.xMax += 1;
            var screen_rect = Screen.safeArea;

            if (r.yMin < screen_rect.yMin)
            {
                r.yMin = screen_rect.yMin;
            }
            if (r.yMax > screen_rect.yMax)
            {
                r.yMax = screen_rect.yMax;
            }
            //if (r.yMax > screen_rect.yMax)
            //    r.y -= (r.yMax - screen_rect.yMax - 20);

            instance.target   = (InstructionSet)prop.GetValue();
            instance.property = prop;
            instance.Enable();
            instance.ShowPopup();
            instance.basePosition = r;
            instance.position     = r;
            instance.Focus();

            if (styleHint == null)
            {
                styleHint         = new GUIStyle(EditorStyles.label);
                styleHintSelected = new GUIStyle(EditorStyles.label);
                Texture2D tex = new Texture2D(1, 1); tex.SetPixel(0, 0, Color.blue); tex.Apply();
                styleHintSelected.normal.background = tex;
                styleHintSelected.normal.textColor  = Color.white;
            }
        }
Ejemplo n.º 5
0
        public static MaterialConversionDialog ShowDialog(ResultCallback resultCallback)
        {
            if (m_instance != null)
            {
                m_instance.CloseDialog();
            }
            m_active         = true;
            m_resultCallback = resultCallback;
            m_instance       = EditorWindow.CreateInstance <MaterialConversionDialog>();

            Vector2 point = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);

            m_instance.position = new Rect(point.x, point.y, 250, 900);
            m_instance.minSize  = new Vector2(250, 900);
            Configure();
            m_instance.ShowUtility();
            return(m_instance);
        }
Ejemplo n.º 6
0
        static void CreateSettingsThenImport(DefaultAsset[] assets)
        {
            var size   = new Vector2(Screen.width, Screen.height);
            var rect   = new Rect(size.x / 2, size.y / 2, 250, 200);
            var window = (CreateSettingsWindow)EditorWindow.CreateInstance(typeof(CreateSettingsWindow));

            window.position = rect;

            var paths = assets.Select(it => GetImportSettingsPath(it)).ToList();

            window._Init(paths, settings => { foreach (var asset in assets)
                                              {
                                                  ASEImporter.Import(asset, settings);
                                              }
                         });

            window.ShowPopup();
        }
        public static BakeSetSettingsDialog ShowDialog(string bakeSetName, List <LightEntry> lightGroups, bool activeSet, bool forceAllLights, ResultCallback resultCallback)
        {
            m_active         = true;
            m_resultCallback = resultCallback;
            BakeSetSettingsDialog window = EditorWindow.CreateInstance <BakeSetSettingsDialog>();

            window.m_activeSet      = activeSet;
            window.m_bakeSetName    = bakeSetName;
            window.m_forceAllLights = forceAllLights;

            Vector2 point = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);

            window.position         = new Rect(point.x, point.y, 250, 300);
            window.m_selectedLights = new List <LightEntry>(lightGroups);
            DDRSettings.GatherLightGroups(ref window.m_groups);
            window.ShowPopup();
            return(window);
        }
Ejemplo n.º 8
0
        public static void      Open()
        {
            Utility.CloseAllEditorWindows(typeof(NGSpotlightWindow));

            POINT pos = new POINT();

            NativeMethods.GetCursorPos(out pos);

            Rect r = Utility.GetEditorMainWindowPos();
            NGSpotlightWindow window = EditorWindow.CreateInstance <NGSpotlightWindow>();

            window.titleContent.text = NGSpotlightWindow.Title;
            window.position          = new Rect(Mathf.Clamp(pos.x - NGSpotlightWindow.WindowWidth * .5F, r.x + 5F, r.xMax - NGSpotlightWindow.WindowWidth - 5F), r.y + r.height * .5F - NGSpotlightWindow.WindowHeight * .5F, NGSpotlightWindow.WindowWidth, NGSpotlightWindow.WindowHeight);
            window.minSize           = new Vector2(NGSpotlightWindow.WindowWidth, NGSpotlightWindow.WindowHeight);
            window.maxSize           = window.minSize;
            window.ShowPopup();
            window.Focus();
        }
        private static bool OpenGraphAsset(int instanceID, int line)
        {
            Debug.Log(instanceID);
            var graphSelected = EditorUtility.InstanceIDToObject(instanceID) as OSM_Graph;

            if (graphSelected != null)
            {
                OSM_EditorWindow windowToUse = null;

                // Try to find an editor window without a graph...
                var windows = Resources.FindObjectsOfTypeAll <OSM_EditorWindow>();
                foreach (var w in windows)
                {
                    // The canvas is already opened
                    if (w.Graph == graphSelected)
                    {
                        return(false);
                    }

                    // Found a window with no active canvas.
                    if (w.Graph == null)
                    {
                        windowToUse = w;
                        break;
                    }
                }

                // No windows available...just make a new one.
                if (!windowToUse)
                {
                    windowToUse = EditorWindow.CreateInstance <OSM_EditorWindow>();
                    windowToUse.titleContent = new GUIContent("Node Editor");
                    windowToUse.Show();
                }

                windowToUse.SetGraph(graphSelected);
                // windowToUse._saveManager.InitState();
                windowToUse.Repaint();

                return(true);
            }

            return(false);
        }
Ejemplo n.º 10
0
        private void    DrawComponent(Rect rect, int i, bool isActive, bool isFocused)
        {
            if (this.hub.components[i].hasEditorGUI == true)
            {
                Rect rect2 = rect;

                rect2.width = 40F;
                rect.xMin  += rect2.width;

                if (Event.current.type == EventType.MouseDown &&
                    rect2.Contains(Event.current.mousePosition) == true)
                {
                    // This condition is required to prevent closing and opening in the same frame when toggling the same component.
                    if (this.skipComponentEditorOpening == true && this.lastEditingComponent == this.hub.components[i])
                    {
                        this.skipComponentEditorOpening = false;
                        return;
                    }

                    HubComponentWindow[] windows = Resources.FindObjectsOfTypeAll <HubComponentWindow>();

                    if (windows.Length > 0)
                    {
                        for (int j = 0; j < windows.Length; j++)
                        {
                            windows[j].Close();
                        }
                    }
                    else
                    {
                        this.componentWindow = EditorWindow.CreateInstance <HubComponentWindow>();
                        this.componentWindow.titleContent.text = this.hub.components[i].name;
                        this.componentWindow.position          = new Rect(this.position.x + rect.x, this.position.y + rect.y + rect.height + this.headerRect.yMax - this.scrollPosition.y, Mathf.Max(HubComponentWindow.MinWidth, this.position.width - rect2.xMax), this.componentWindow.position.height);
                        this.componentWindow.Init(this, this.hub.components[i]);
                        this.componentWindow.ShowPopup();
                        this.componentWindow.Focus();
                    }
                }

                GUI.Button(rect2, "Edit");
            }

            this.hub.components[i].OnPreviewGUI(rect);
        }
Ejemplo n.º 11
0
        private static bool OpenCanvasAsset(int instanceID, int line)
        {
            var treeSelected = EditorUtility.InstanceIDToObject(instanceID) as Core.BehaviourTree;

            if (treeSelected != null)
            {
                BonsaiWindow windowToUse = null;

                // Try to find an editor window without a canvas...
                var bonsaiWindows = Resources.FindObjectsOfTypeAll <BonsaiWindow>();
                foreach (var w in bonsaiWindows)
                {
                    // The canvas is already opened
                    if (w.tree == treeSelected)
                    {
                        return(false);
                    }

                    // Found a window with no active canvas.
                    if (w.tree == null)
                    {
                        windowToUse = w;
                        break;
                    }
                }

                // No windows available...just make a new one.
                if (!windowToUse)
                {
                    windowToUse = EditorWindow.CreateInstance <BonsaiWindow>();
                    windowToUse.titleContent = new GUIContent("Bonsai");
                    windowToUse.Show();
                }

                windowToUse.SetTree(treeSelected);
                windowToUse.saveManager.InitState();
                windowToUse.Repaint();

                return(true);
            }

            return(false);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Static update function that is passed to the editor on load and is responsible for handling the updater states
        /// </summary>
        static void Update()
        {
            updater.Update();

            switch (updater.GetState())
            {
            case UpdaterState.Fetching:
                break;

            // If the updater found an update a popup window is created to inform the user that an update is available
            case UpdaterState.Ready:
                if (window == null)
                {
                    Debug.Log("Toony standard: new update found");
                    int windowWidth  = 500;
                    int windowHeight = 320;
                    window              = EditorWindow.CreateInstance <TSAutoUpdatePopup>();
                    window.updater      = updater;
                    window.update       = Update;
                    window.minSize      = new Vector2(windowWidth, windowHeight);
                    window.maxSize      = new Vector2(windowWidth, windowHeight);
                    window.titleContent = new GUIContent("Toony Standard Updater");
                    window.ShowUtility();
                }

                break;

            case UpdaterState.UpToDate:
                Debug.Log("Toony standard: shader is up to date");
                EditorApplication.update -= Update;
                break;

            case UpdaterState.Error:
                Debug.Log("Toony standard: error on getting update information");
                EditorApplication.update -= Update;
                break;

            case UpdaterState.Downloaded:
                window.Close();
                EditorApplication.update -= Update;
                break;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// The popup dialog that prompts for a name for the new Folder Entry
        /// </summary>
        /// <param name="entry">Optional parent</param>
        public static void ShowNewFolderEntryDialog(GenericHierarchyEntry entry)
        {
            // show dialog to get the desired name of the new entry
            var dialog = EditorWindow.CreateInstance <DialogGetNewEntryName>();

            {
                dialog.entry         = entry;
                dialog.dialogTitle   = Loc.DIALOG_ADDNEWENTRY_TITLE;
                dialog.dialogMessage = Loc.DIALOG_ADDNEWENTRY_MESSAGE;

                // make sure the dialog is centered
                var dialogPosition = dialog.position;
                dialogPosition.center = new Rect(0f, 0f, Screen.currentResolution.width, Screen.currentResolution.height).center;
                dialog.position       = dialogPosition;
                dialog.maxSize        = new Vector2(250f, 110f);
                dialog.minSize        = new Vector2(250f, 110f);
            }
            dialog.ShowUtility();
        }
Ejemplo n.º 14
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.º 15
0
        static void EditAssetSettings()
        {
            var aseprites = GetSelectedAseprites();
            var path      = GetImportSettingsPath(aseprites[0]);
            var ret       = (ImportSettingsReference)AssetDatabase.LoadAssetAtPath(path, typeof(ImportSettingsReference));

            if (ret == null)
            {
                ret = ScriptableObject.CreateInstance <ImportSettingsReference>();
                AssetDatabase.CreateAsset(ret, path);
            }

            var size   = new Vector2(Screen.width, Screen.height);
            var rect   = new Rect(size.x / 2, size.y / 2, 250, 200);
            var window = (InspectSettingsWindow)EditorWindow.CreateInstance(typeof(InspectSettingsWindow));

            window.position = rect;
            window._Init(ret);
            window.ShowPopup();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Not yet documented.
        /// </summary>
        public static void Show(Type type, int controlId, Rect buttonRect = default(Rect))
        {
            Type      = type;
            ControlID = controlId;

            var window = EditorWindow.CreateInstance <InstanceCreatorWindow>();

            window.Initialize();

            if (Event.current != null && Event.current.modifiers == EventModifiers.Control)
            {
                UnityEngine.Object.DestroyImmediate(window);
                return;
            }

            if (buttonRect.width > 0 && buttonRect.height > 0)
            {
                var prevWidth = buttonRect.width;
                buttonRect.width = Mathf.Clamp(prevWidth, 250, 500);
                buttonRect.x    += (prevWidth - buttonRect.width);

                var windowSize = new Vector2(buttonRect.width, Mathf.Min(buttonRect.width, window.GetWindowHeight()));

                if (Event.current != null)
                {
                    buttonRect.position = GUIUtility.GUIToScreenPoint(buttonRect.position);
                }

                window.ShowAsDropDown(buttonRect, windowSize);
            }
            else
            {
                var windowSize = new Vector2(500, 500);
                var windowRect = GUIHelper.GetEditorWindowRect();
                window.ShowAuxWindow();
                window.position = new Rect(windowRect.center - windowSize * 0.5f, new Vector2(windowSize.x, window.GetWindowHeight()));
            }

            window.minSize = new Vector2(20, 20);
            window.maxSize = window.position.size;
        }
Ejemplo n.º 17
0
        int myParentSelection    = 0;           //< The parent package selection

        // =================================================================================
        /// Creates a package selection window.
        public static PackageSelectionWindow Init()
        {
            // -- Create window. --
            var editor = EditorWindow.CreateInstance <PackageSelectionWindow>();

            editor.wantsMouseMove = true;

            // -- Set window title --
            Texture2D iCanScriptLogo = null;

            TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo);
            editor.titleContent = new GUIContent("iCanScript Package Selection", iCanScriptLogo);

            // -- Fix window size. --
            editor.minSize = new Vector2(kWidth, kHeaderHeight + kListAreaHeight);
            editor.maxSize = new Vector2(kWidth, kHeaderHeight + kListAreaHeight);

            // -- Show the window. --
            editor.ShowUtility();
            return(editor);
        }
Ejemplo n.º 18
0
        public void OnGUIShowFullScreenViews()
        {
            if (GUILayout.Button("Show Full-Screen Views"))
            {
                // Avoid showing redundant FullScreenViews by closing all of them before (re)showing all of them.

                List <FullScreenView> views = new List <FullScreenView>(FullScreenView.views);
                foreach (FullScreenView view in views)
                {
                    view.Close();
                }

                foreach (Monitor monitor in _monitors)
                {
                    Camera camera = (Camera)EditorUtility.InstanceIDToObject(monitor.cameraInstanceId);
                    if (camera != null)
                    {
                        FullScreenView window = EditorWindow.CreateInstance <FullScreenView>();

                        // Negative coordinates must be scaled by the pixelsPerPoint for the target monitor, but
                        // positive coordinates must be scaled by the pixelsPerPoint of the main monitor.

                        float pixelsPerPointX = (monitor.left < 0) ? monitor.pixelsPerPoint : _monitors[0].pixelsPerPoint;
                        int   x = (int)(monitor.left / pixelsPerPointX);
                        float pixelsPerPointY = (monitor.top < 0) ? monitor.pixelsPerPoint : _monitors[0].pixelsPerPoint;
                        int   y = (int)(monitor.top / pixelsPerPointY);

                        int width  = (int)(monitor.width / monitor.pixelsPerPoint);
                        int height = (int)(monitor.height / monitor.pixelsPerPoint);

                        window.position         = new Rect(x, y, width, height);
                        window.cameraInstanceId = camera.GetInstanceID();

                        // Using ShowPopup() eliminates all borders and window decorations.

                        window.ShowPopup();
                    }
                }
            }
        }
Ejemplo n.º 19
0
        private void    OnCreateComponent(Type type)
        {
            if (this.CheckMaxHubComponents(this.components.Count) == false)
            {
                return;
            }

            HubComponent component = Activator.CreateInstance(type) as HubComponent;

            component.Init(this);

            HubComponentWindow[] editors = Resources.FindObjectsOfTypeAll <HubComponentWindow>();

            for (int i = 0; i < editors.Length; i++)
            {
                editors[i].Close();
            }

            if (component.hasEditorGUI == true)
            {
                HubComponentWindow editor = EditorWindow.CreateInstance <HubComponentWindow>();

                editor.titleContent.text = component.name;
                editor.position          = new Rect(this.position.x, this.position.y + this.height, Mathf.Max(HubComponentWindow.MinWidth, editor.position.width), editor.position.height);
                editor.Init(this, component);
                editor.ShowPopup();
            }

            this.components.Add(component);
            this.SaveComponents();
            this.Repaint();

            NGHubEditorWindow[] windows = Resources.FindObjectsOfTypeAll <NGHubEditorWindow>();

            for (int i = 0; i < windows.Length; i++)
            {
                windows[i].Repaint();
            }
        }
Ejemplo n.º 20
0
        private void ShowUpdatePrompt(string _title, string _message, string _description = null, string[] _buttons = null)
        {
            if (m_promptWindow == null)
            {
                m_promptWindow = EditorWindow.CreateInstance <UpdatePromptWindow>();
            }

            // Set properties
                        #if !(UNITY_5_0) && (UNITY_5 || UNITY_6 || UNITY_7)
            m_promptWindow.titleContent = new GUIContent(_title);
                        #else
            m_promptWindow.title = _title;
                        #endif
            m_promptWindow.Message           = _message;
            m_promptWindow.Description       = _description;
            m_promptWindow.Buttons           = _buttons;
            m_promptWindow.LogoTexture       = LogoTexture;
            m_promptWindow.CallbackOnDismiss = OnUpdatePromptDismissed;

            // Show window
            m_promptWindow.ShowUtility();
        }
Ejemplo n.º 21
0
        public void DrawClipList()
        {
            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Sound clips");

            if (GUILayout.Button("Nuke"))
            {
                EditorWindow.CreateInstance <ConfirmActionPopup>()
                .SetQuestion("You're about to remove all soundclips. Are you sure?")
                .CenterOnRect(_CurrentWindow.position)
                .OnConfirm += RemoveAllElements;
            }

            if (GUILayout.Button("Remove"))
            {
                RemoveElement();
            }

            if (GUILayout.Button("Add"))
            {
                AddElement();
            }
            GUILayout.EndHorizontal();


            _SelectableList.DoList(_ClipList.arraySize, _ScrollVector);
            GUILayout.EndVertical();

            AudioClip[] audioclips = EditorScriptUtil.FilteredDrop <AudioClip>();

            if (audioclips != null)
            {
                foreach (AudioClip clip in audioclips)
                {
                    AddClip(clip);
                }
            }
        }
Ejemplo n.º 22
0
        private static void     Open()
        {
            if (NGChangeLogWindow.updateNotificationWindow == null)
            {
                NGChangeLogWindow.updateNotificationWindow         = EditorWindow.CreateInstance <NGChangeLogWindow>();
                NGChangeLogWindow.updateNotificationWindow.name    = NGChangeLogWindow.Title;
                NGChangeLogWindow.updateNotificationWindow.minSize = new Vector2(400F, 350F);
                NGChangeLogWindow.updateNotificationWindow.maxSize = NGChangeLogWindow.updateNotificationWindow.minSize;

                Rect r = Utility.GetEditorMainWindowPos();
                r.x     += r.width / 2F - 200F;
                r.y     += r.height / 2F - 175F;
                r.width  = 400F;
                r.height = 350F;
                NGChangeLogWindow.updateNotificationWindow.position = r;
                NGChangeLogWindow.updateNotificationWindow.ShowPopup();
            }
            else
            {
                NGChangeLogWindow.updateNotificationWindow.Repaint();
            }
        }
Ejemplo n.º 23
0
    public static U Create(T target, bool isField)
    {
        EditorWindow.GetWindow <U>().Close();

        var window = EditorWindow.CreateInstance <U>();

        window.target       = target;
        window.isField      = isField;
        window.titleContent = new GUIContent("Utility");

        window.OnSetupAuxWindow();

        window.position = new Rect(100, 100, window.minSize.x, window.minSize.y);
        window.ShowUtility();

        SGT_AuxWindowHelper.instance = window;

        //window.ShowAuxWindow(); - Doesn't seem to work on mac properly with the rest of my UI?
        EditorGUIUtility.keyboardControl = 0;

        return(window);
    }
Ejemplo n.º 24
0
        public static void CreatePopup(Rect iconPosition)
        {
            float windowWidth  = 128f;
            float windowHeight = kLayerEntryHeight * (sLayerNames.Length);
            Rect  windowPos    = new Rect(iconPosition);

            windowPos.width  = windowWidth + sShadowOffset.x;
            windowPos.height = windowHeight + sShadowOffset.y;

            Vector2 windowCentre = new Vector2(windowPos.x, iconPosition.center.y);

            windowCentre.y = Mathf.Clamp(windowPos.center.y, 0f, (Screen.height - (windowHeight * 0.5f)) - (EditorGUIUtility.singleLineHeight * 2));

            windowPos.center = GUIUtility.GUIToScreenPoint(windowCentre);
            windowPos.x     -= windowWidth * 0.5f;

            sPopupWindow                = EditorWindow.CreateInstance <LayerSelectPopupWindow>();
            sPopupWindow.position       = windowPos;
            sPopupWindow.wantsMouseMove = true;
            sPopupWindow.ShowPopup();
            sPopupWindow.Focus();
        }
Ejemplo n.º 25
0
        public static int GetGameDesignerEditorInstance()
        {
            if (gameDesignerEditors == null)
            {
                gameDesignerEditors = new Dictionary <int, GameDesignerEditor>();

                var GameDesignerEditorProfiles = AssetFinder.SafeAssetFind <GameDesignerEditorProfile>("t:" + typeof(GameDesignerEditorProfile).Name);
                foreach (var GameDesignerEditorProfile in GameDesignerEditorProfiles)
                {
                    gameDesignerEditors[GameDesignerEditorProfile.GameDesignerProfileInstanceIndex] = null;
                }
            }

            int pickedIndex = 0;

            if (gameDesignerEditors.Count > 0)
            {
                var  maxIndex     = gameDesignerEditors.Keys.ToList().Max();
                bool hasFoundPick = false;
                for (var i = 0; i < maxIndex; i++)
                {
                    if (!gameDesignerEditors.ContainsKey(i) || gameDesignerEditors[i] == null)
                    {
                        pickedIndex  = i;
                        hasFoundPick = true;
                        break;
                    }
                }

                if (!hasFoundPick)
                {
                    pickedIndex = maxIndex + 1;
                }
            }

            gameDesignerEditors[pickedIndex] = (GameDesignerEditor)EditorWindow.CreateInstance(typeof(GameDesignerEditor));
            return(pickedIndex);
        }
Ejemplo n.º 26
0
        public void DoList()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label($"{nameof(AudioLibraryList)}");

            if (GUILayout.Button("Create New Library"))
            {
                EditorWindow.CreateInstance <CreateAudioLibraryAssetPopup>()
                .SetFolder("Assets/Audio/Resources/")
                .CenterOnRect(_CurrentWindow.position)
                .OnCreated += OnNewElementcreated;
            }

            if (GUILayout.Button("Delete"))
            {
                RemoveSelectedElement();
            }

            GUILayout.EndHorizontal();
            _ScrollPosition = EditorGUILayout.BeginScrollView(_ScrollPosition);
            _SelectionList.DoList(_AssetLabels.Length, _ScrollPosition);
            EditorGUILayout.EndScrollView();
        }
Ejemplo n.º 27
0
        private void Start()
        {
            Assembly asm         = Assembly.GetAssembly(typeof(UnityEditor.Editor));
            Type     windowType  = asm.GetType(m_WindowClass);
            Type     guiViewType = asm.GetType("UnityEditor.GUIView");

            if (windowType != null && guiViewType != null)
            {
                m_Window = EditorWindow.CreateInstance(windowType) as EditorWindow;

                // AE: The first assignment is to undock the window if it was docked and the second is to position it off screen
                //window.position = rect;
                m_Window.Show();
                m_Window.position = m_Position;

                // NOTE: Uncomment To grab any and all GUIViews
                //foreach (UnityEngine.Object view in Resources.FindObjectsOfTypeAll(guiViewType))
                //{
                //    Debug.Log(view.name);
                //}

                FieldInfo parentField = windowType.GetField("m_Parent", BindingFlags.Instance | BindingFlags.NonPublic);
                m_GuiView = (Object)parentField.GetValue(m_Window);

                // It's necessary to force a repaint on first start-up of window
                MethodInfo repaint = windowType.GetMethod("RepaintImmediately", BindingFlags.Instance | BindingFlags.NonPublic);
                repaint.Invoke(m_Window, null);

                m_GrabPixels = guiViewType.GetMethod("GrabPixels", BindingFlags.Instance | BindingFlags.NonPublic);

                capture = true;
            }
            else
            {
                Debug.LogError("Could not load " + m_WindowClass);
            }
        }
Ejemplo n.º 28
0
    void OnGUI()
    {
        GUILayout.Label("Android Manifest Manager", EditorStyles.boldLabel);

        if (!AN_ManifestManager.HasManifest)
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            GUILayout.Label("You have NO AndroidManifest file in your project!", GUILayout.Width(300.0f));
            EditorGUILayout.Space();
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            if (GUILayout.Button("Create Default Manifest", new GUILayoutOption[] { GUILayout.Width(200.0f), GUILayout.Height(50.0f) }))
            {
                AN_ManifestManager.CreateDefaultManifest();
            }
            EditorGUILayout.Space();
            GUILayout.EndHorizontal();
        }
        else
        {
            string[] toolbarButtons = new string[] { "Manifest", "Application", "Permissions" };
            toolbarButtonIndex = GUILayout.Toolbar(toolbarButtonIndex, toolbarButtons, new GUILayoutOption[] { GUILayout.Height(30.0f) });

            switch (toolbarButtons[toolbarButtonIndex])
            {
            case "Manifest": {
                AN_ManifestTemplate manifest = AN_ManifestManager.GetManifest();

                if (manifest != null)
                {
                    GUILayout.Label("Values", EditorStyles.boldLabel);
                    foreach (string key in manifest.Values.Keys)
                    {
                        EditorGUILayout.BeginHorizontal();

                        GUILayout.Label(key);
                        if (key.Equals("xmlns:android") ||
                            key.Equals("android:installLocation") ||
                            key.Equals("package") ||
                            key.Equals("android:versionName") ||
                            key.Equals("android:versionCode") ||
                            key.Equals("android:theme"))
                        {
                            GUI.enabled = false;
                            GUILayout.TextField(AN_ManifestManager.GetManifest().Values[key], GUILayout.Width(300.0f));
                        }
                        else
                        {
                            GUI.enabled = true;

                            string input = AN_ManifestManager.GetManifest().Values[key];
                            EditorGUI.BeginChangeCheck();
                            input = GUILayout.TextField(AN_ManifestManager.GetManifest().Values[key], GUILayout.Width(276.0f));
                            if (EditorGUI.EndChangeCheck())
                            {
                                AN_ManifestManager.GetManifest().SetValue(key, input);
                                return;
                            }

                            if (GUILayout.Button("X", GUILayout.Width(20.0f)))
                            {
                                AN_ManifestManager.GetManifest().RemoveValue(key);
                                return;
                            }
                        }
                        GUI.enabled = true;
                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    if (GUILayout.Button("Add Value", GUILayout.Width(100.0f)))
                    {
                        AddValueDialog(AN_ManifestManager.GetManifest());
                    }
                    EditorGUILayout.Space();
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Label("Properties", EditorStyles.boldLabel);
                    DrawProperties(AN_ManifestManager.GetManifest());

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    if (GUILayout.Button("Add Property", GUILayout.Width(100.0f)))
                    {
                        AddPropertyDialog(AN_ManifestManager.GetManifest());
                    }
                    EditorGUILayout.Space();
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();

                    EditorGUILayout.Space();
                    if (GUILayout.Button("Save Manifest", GUILayout.Height(22.0f)))
                    {
                        AN_ManifestManager.SaveManifest();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Selected build platform DOESN'T support AndroidManifest.xml file", MessageType.Info);
                }
            } break;

            case "Application": {
                AN_ManifestTemplate manifest = AN_ManifestManager.GetManifest();

                if (manifest != null)
                {
                    scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 50f));

                    GUILayout.Label("Values", EditorStyles.boldLabel);
                    foreach (string key in manifest.ApplicationTemplate.Values.Keys)
                    {
                        EditorGUILayout.BeginHorizontal();

                        GUILayout.Label(key);

                        string input = AN_ManifestManager.GetManifest().ApplicationTemplate.Values[key];
                        EditorGUI.BeginChangeCheck();
                        input = GUILayout.TextField(AN_ManifestManager.GetManifest().ApplicationTemplate.Values[key], GUILayout.Width(200.0f));
                        if (EditorGUI.EndChangeCheck())
                        {
                            AN_ManifestManager.GetManifest().ApplicationTemplate.SetValue(key, input);
                            return;
                        }

                        if (GUILayout.Button("X", GUILayout.Width(20.0f)))
                        {
                            AN_ManifestManager.GetManifest().ApplicationTemplate.RemoveValue(key);
                            return;
                        }

                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    if (GUILayout.Button("Add Value", GUILayout.Width(100.0f)))
                    {
                        AddValueDialog(AN_ManifestManager.GetManifest().ApplicationTemplate);
                    }
                    EditorGUILayout.Space();
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Label("Activities", EditorStyles.boldLabel);

                    int launcherActivities = 0;
                    foreach (int id in AN_ManifestManager.GetManifest().ApplicationTemplate.Activities.Keys)
                    {
                        AN_ActivityTemplate activity = AN_ManifestManager.GetManifest().ApplicationTemplate.Activities[id];

                        if (activity.IsLauncher)
                        {
                            launcherActivities++;
                        }

                        EditorGUILayout.BeginVertical(GUI.skin.box);
                        EditorGUILayout.BeginHorizontal();
                        activity.IsOpen = EditorGUILayout.Foldout(activity.IsOpen, activity.Name);
                        if (GUILayout.Button("X", GUILayout.Width(20.0f)))
                        {
                            AN_ManifestManager.GetManifest().ApplicationTemplate.RemoveActivity(activity);
                            return;
                        }
                        EditorGUILayout.EndHorizontal();

                        if (activity.IsOpen)
                        {
                            EditorGUILayout.BeginVertical();

                            bool isLauncher = activity.IsLauncher;
                            EditorGUI.BeginChangeCheck();
                            isLauncher = EditorGUILayout.Toggle("Is Launcher", activity.IsLauncher);
                            if (EditorGUI.EndChangeCheck())
                            {
                                activity.SetAsLauncher(isLauncher);
                            }

                            foreach (string k in activity.Values.Keys)
                            {
                                EditorGUILayout.BeginHorizontal();

                                GUILayout.Label(k);
                                EditorGUILayout.Space();

                                string input = activity.Values[k];
                                EditorGUI.BeginChangeCheck();

                                if (k.Equals("android:name"))
                                {
                                    input = GUILayout.TextField(activity.Values[k], GUILayout.Width(224.0f));
                                }
                                else
                                {
                                    input = GUILayout.TextField(activity.Values[k], GUILayout.Width(200.0f));
                                }

                                if (EditorGUI.EndChangeCheck())
                                {
                                    activity.SetValue(k, input);
                                    return;
                                }

                                if (!k.Equals("android:name"))
                                {
                                    if (GUILayout.Button("X", GUILayout.Width(20.0f)))
                                    {
                                        activity.RemoveValue(k);
                                        return;
                                    }
                                }

                                EditorGUILayout.EndHorizontal();
                                EditorGUILayout.Space();
                            }

                            DrawProperties(activity);

                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.Space();
                            if (GUILayout.Button("Add Value", GUILayout.Width(100.0f)))
                            {
                                AddValueDialog(activity);
                            }
                            if (GUILayout.Button("Add Property", GUILayout.Width(100.0f)))
                            {
                                AddPropertyDialog(activity);
                            }
                            EditorGUILayout.Space();
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.Space();

                            EditorGUILayout.EndVertical();
                        }
                        EditorGUILayout.EndVertical();
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    if (GUILayout.Button("Add Activity", GUILayout.Width(100.0f)))
                    {
                        AddPermissionDialog dlg = EditorWindow.CreateInstance <AddPermissionDialog>();
                        dlg.onClose    += OnPermissionDlgClose;
                        dlg.onAddClick += OnAddActivityClick;

                                                #if UNITY_5 && !UNITY_5_0
                        dlg.titleContent.text = "Add Activity";
                                                #else
                        dlg.title = "Add Activity";
                                                #endif

                        dlg.ShowAuxWindow();
                    }
                    EditorGUILayout.Space();
                    EditorGUILayout.EndHorizontal();

                    if (launcherActivities > 1)
                    {
                        EditorGUILayout.HelpBox("There is MORE THAN ONE Launcher Activity in Manifest", MessageType.Warning);
                    }
                    else if (launcherActivities < 1)
                    {
                        EditorGUILayout.HelpBox("There is NO Launcher Activities in Manifest", MessageType.Warning);
                    }

                    GUILayout.Label("Properties", EditorStyles.boldLabel);
                    DrawProperties(AN_ManifestManager.GetManifest().ApplicationTemplate);

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    if (GUILayout.Button("Add Property", GUILayout.Width(100.0f)))
                    {
                        AddPropertyDialog(AN_ManifestManager.GetManifest().ApplicationTemplate);
                    }
                    EditorGUILayout.Space();
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.Space();
                    EditorGUILayout.EndScrollView();
                }
                else
                {
                    EditorGUILayout.HelpBox("Selected build platform DOESN'T support AndroidManifest.xml file", MessageType.Info);
                }
            } break;

            case "Permissions": {
                AN_ManifestTemplate manifest = AN_ManifestManager.GetManifest();

                if (manifest != null)
                {
                    scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 50f));
                    EditorGUILayout.BeginVertical();

                    foreach (AN_PropertyTemplate permission in AN_ManifestManager.GetManifest().Permissions)
                    {
                        EditorGUILayout.BeginHorizontal(GUI.skin.box);
                        EditorGUILayout.LabelField(permission.Values["android:name"]);
                        if (GUILayout.Button("X", GUILayout.Width(20.0f)))
                        {
                            AN_ManifestManager.GetManifest().RemovePermission(permission);
                            return;
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Add Android Permission"))
                    {
                        GenericMenu permissionsMenu = new GenericMenu();
                        foreach (string pStr in PermissionsStrings)
                        {
                            permissionsMenu.AddItem(new GUIContent(pStr), false, SelectPermission, pStr);
                        }
                        permissionsMenu.ShowAsContext();
                    }

                    if (GUILayout.Button("Add Other Permission"))
                    {
                        AddPermissionDialog dlg = EditorWindow.CreateInstance <AddPermissionDialog>();
                        dlg.onClose    += OnPermissionDlgClose;
                        dlg.onAddClick += OnAddPermissionClick;

                                                #if UNITY_5 && !UNITY_5_0
                        dlg.titleContent.text = "Add Permission";
                                                #else
                        dlg.title = "Add Permission";
                                                #endif


                        dlg.ShowAuxWindow();
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.Space();
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.EndScrollView();
                }
                else
                {
                    EditorGUILayout.HelpBox("Selected build platform DOESN'T support AndroidManifest.xml file", MessageType.Info);
                }
            } break;

            default: break;
            }


            AboutGUI();
        }
    }
Ejemplo n.º 29
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Texture browseIcon = EditorGUIUtility.Load("FMOD/SearchIconBlack.png") as Texture;
            Texture openIcon   = EditorGUIUtility.Load("FMOD/BrowserIcon.png") as Texture;
            Texture addIcon    = EditorGUIUtility.Load("FMOD/AddIcon.png") as Texture;

            EditorGUI.BeginProperty(position, label, property);
            SerializedProperty pathProperty = property;

            Event e = Event.current;

            if (e.type == EventType.dragPerform && position.Contains(e.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef))
                {
                    pathProperty.stringValue = ((EditorEventRef)DragAndDrop.objectReferences[0]).Path;
                    GUI.changed = true;
                    e.Use();
                }
            }
            if (e.type == EventType.DragUpdated && position.Contains(e.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    DragAndDrop.AcceptDrag();
                    e.Use();
                }
            }

            float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y;

            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);

            buttonStyle.padding.top    = 1;
            buttonStyle.padding.bottom = 1;

            Rect addRect    = new Rect(position.x + position.width - addIcon.width - 7, position.y, addIcon.width + 7, baseHeight);
            Rect openRect   = new Rect(addRect.x - openIcon.width - 7, position.y, openIcon.width + 6, baseHeight);
            Rect searchRect = new Rect(openRect.x - browseIcon.width - 9, position.y, browseIcon.width + 8, baseHeight);
            Rect pathRect   = new Rect(position.x, position.y, searchRect.x - position.x - 3, baseHeight);

            EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none);

            if (GUI.Button(searchRect, new GUIContent(browseIcon, "Search"), buttonStyle))
            {
                var eventBrowser = EventBrowser.CreateInstance <EventBrowser>();

                eventBrowser.SelectEvent(property);
                var windowRect = position;
                windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position);
                windowRect.height   = openRect.height + 1;
                eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400));
            }
            if (GUI.Button(addRect, new GUIContent(addIcon, "Create New Event in Studio"), buttonStyle))
            {
                var addDropdown = EditorWindow.CreateInstance <CreateEventPopup>();

                addDropdown.SelectEvent(property);
                var windowRect = position;
                windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position);
                windowRect.height   = openRect.height + 1;
                addDropdown.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 500));
            }
            if (GUI.Button(openRect, new GUIContent(openIcon, "Open In Browser"), buttonStyle) &&
                !String.IsNullOrEmpty(pathProperty.stringValue) &&
                EventManager.EventFromPath(pathProperty.stringValue) != null
                )
            {
                EventBrowser.ShowEventBrowser();
                var eventBrowser = EditorWindow.GetWindow <EventBrowser>();
                eventBrowser.JumpToEvent(pathProperty.stringValue);
            }

            if (!String.IsNullOrEmpty(pathProperty.stringValue) && EventManager.EventFromPath(pathProperty.stringValue) != null)
            {
                Rect foldoutRect = new Rect(position.x + 10, position.y + baseHeight, position.width, baseHeight);
                property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, "Event Properties");
                if (property.isExpanded)
                {
                    var style = new GUIStyle(GUI.skin.label);
                    style.richText = true;
                    EditorEventRef eventRef  = EventManager.EventFromPath(pathProperty.stringValue);
                    float          width     = style.CalcSize(new GUIContent("<b>Oneshot</b>")).x;
                    Rect           labelRect = new Rect(position.x, position.y + baseHeight * 2, width, baseHeight);
                    Rect           valueRect = new Rect(position.x + width + 10, position.y + baseHeight * 2, pathRect.width, baseHeight);

                    GUI.Label(labelRect, new GUIContent("<b>GUID</b>"), style);
                    EditorGUI.SelectableLabel(valueRect, eventRef.Guid.ToString("b"));
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Banks</b>"), style);
                    StringBuilder builder = new StringBuilder();
                    eventRef.Banks.ForEach((x) => { builder.Append(Path.GetFileNameWithoutExtension(x.Path)); builder.Append(", "); });
                    GUI.Label(valueRect, builder.ToString(0, builder.Length - 2));
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Panning</b>"), style);
                    GUI.Label(valueRect, eventRef.Is3D ? "3D" : "2D");
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Stream</b>"), style);
                    GUI.Label(valueRect, eventRef.IsStream.ToString());
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Oneshot</b>"), style);
                    GUI.Label(valueRect, eventRef.IsOneShot.ToString());
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;
                }
            }
            else
            {
                Rect labelRect = new Rect(position.x, position.y + baseHeight, position.width, baseHeight);
                GUI.Label(labelRect, new GUIContent("Event Not Found", EditorGUIUtility.Load("FMOD/NotFound.png") as Texture2D));
            }

            EditorGUI.EndProperty();
        }
Ejemplo n.º 30
0
    static void Init()
    {
        AttackImporter window = (AttackImporter)EditorWindow.CreateInstance(typeof(AttackImporter));

        window.Show();
    }