예제 #1
0
 private static void CloseWindow()
 {
     if (window == null)
     {
         return;
     }
     window?.Close();
 }
 private void CreateLibraryAndCloseWindow(EditorWindow editorWindow)
 {
     PresetFileLocation location = s_Texts.fileLocationOrder[this.m_SelectedIndexInPopup];
     this.m_ErrorString = this.m_CreateLibraryCallback(this.m_NewLibraryName, location);
     if (string.IsNullOrEmpty(this.m_ErrorString))
     {
         editorWindow.Close();
     }
 }
        private void KeyboardHandling(EditorWindow editorWindow)
        {
            Event current = Event.current;
            if (current.type == EventType.KeyDown)
            {
                switch (current.keyCode)
                {
                    case KeyCode.KeypadEnter:
                    case KeyCode.Return:
                        this.CreateLibraryAndCloseWindow(editorWindow);
                        break;

                    case KeyCode.Escape:
                        editorWindow.Close();
                        break;
                }
            }
        }
        private void SelectItem(TreeViewItem item)
        {
            if (item is GameObjectItem gameObjectItem)
            {
                if (Selection.activeTransform?.gameObject != gameObjectItem.gameObject)
                {
                    Selection.activeTransform = gameObjectItem.gameObject.transform;
                    parentWindow?.Close();
                }

                switch (PeekPlugin.Configuration.hierarchyFraming)
                {
                case HierarchyFramingOption.Always: SceneView.lastActiveSceneView?.FrameSelected(); break;

                case HierarchyFramingOption.WhenOutOfView: SceneView.lastActiveSceneView?.FrameSelectedIfOutOfView(); break;
                }

                GUIUtility.ExitGUI();
            }
        }
 private void KeyboardHandling(EditorWindow editorWindow)
 {
     Event current = Event.current;
     if (current.type == EventType.KeyDown)
     {
         KeyCode keyCode = current.keyCode;
         if (keyCode != KeyCode.Return)
         {
             if (keyCode == KeyCode.Escape)
             {
                 editorWindow.Close();
                 return;
             }
             if (keyCode != KeyCode.KeypadEnter)
             {
                 return;
             }
         }
         this.CreateLibraryAndCloseWindow(editorWindow);
     }
 }
 private void DoShaderVariants(EditorWindow caller, ref Rect drawPos)
 {
     EditorGUI.BeginChangeCheck();
     bool usedBySceneOnly = GUI.Toggle(drawPos, currentVariantStripping == 1, EditorGUIUtility.TempContent("Skip unused shader_features"), Styles.menuItem);
     drawPos.y += 16f;
     if (EditorGUI.EndChangeCheck())
     {
         currentVariantStripping = !usedBySceneOnly ? 0 : 1;
     }
     drawPos.y += 6f;
     int comboCount = ShaderUtil.GetComboCount(this.m_Shader, usedBySceneOnly);
     string text = !usedBySceneOnly ? (comboCount + " variants total") : (comboCount + " variants included");
     Rect position = drawPos;
     position.x += Styles.menuItem.padding.left;
     position.width -= Styles.menuItem.padding.left + 4;
     GUI.Label(position, text);
     position.xMin = position.xMax - 40f;
     if (GUI.Button(position, "Show", EditorStyles.miniButton))
     {
         ShaderUtil.OpenShaderCombinations(this.m_Shader, usedBySceneOnly);
         caller.Close();
         GUIUtility.ExitGUI();
     }
 }
예제 #7
0
		private void DrawCustomTextField(EditorWindow editorWindow, Rect windowRect)
		{
			if (!this.m_Data.m_AllowCustom)
			{
				return;
			}
			Event current = Event.current;
			bool flag = true;
			bool flag2 = false;
			bool flag3 = false;
			bool flag4 = false;
			string text = this.CurrentDisplayedText();
			if (current.type == EventType.KeyDown)
			{
				KeyCode keyCode = current.keyCode;
				switch (keyCode)
				{
				case KeyCode.Backspace:
					goto IL_12C;
				case KeyCode.Tab:
					goto IL_AB;
				case (KeyCode)10:
				case (KeyCode)11:
				case KeyCode.Clear:
					IL_5D:
					if (keyCode == KeyCode.UpArrow)
					{
						this.ChangeSelectedCompletion(-1);
						flag3 = true;
						goto IL_170;
					}
					if (keyCode == KeyCode.DownArrow)
					{
						this.ChangeSelectedCompletion(1);
						flag3 = true;
						goto IL_170;
					}
					if (keyCode == KeyCode.None)
					{
						if (current.character == ' ' || current.character == ',')
						{
							flag3 = true;
						}
						goto IL_170;
					}
					if (keyCode == KeyCode.Space)
					{
						goto IL_AB;
					}
					if (keyCode == KeyCode.Comma)
					{
						goto IL_AB;
					}
					if (keyCode != KeyCode.Delete)
					{
						goto IL_170;
					}
					goto IL_12C;
				case KeyCode.Return:
					goto IL_AB;
				}
				goto IL_5D;
				IL_AB:
				if (text != string.Empty)
				{
					if (this.m_Data.m_OnSelectCallback != null)
					{
						this.m_Data.m_OnSelectCallback(this.m_Data.NewOrMatchingElement(text));
					}
					if (current.keyCode == KeyCode.Tab || current.keyCode == KeyCode.Comma)
					{
						flag4 = true;
					}
					if (this.m_Data.m_CloseOnSelection || current.keyCode == KeyCode.Return)
					{
						flag2 = true;
					}
				}
				flag3 = true;
				goto IL_170;
				IL_12C:
				flag = false;
			}
			IL_170:
			bool flag5 = false;
			Rect rect = new Rect(5f, (this.m_Gravity != PopupList.Gravity.Top) ? (windowRect.height - 16f - 5f) : 5f, windowRect.width - 10f - 14f, 16f);
			GUI.SetNextControlName(PopupList.s_TextFieldName);
			EditorGUI.FocusTextInControl(PopupList.s_TextFieldName);
			int controlID = GUIUtility.GetControlID(PopupList.s_TextFieldHash, FocusType.Keyboard, rect);
			if (flag3)
			{
				current.Use();
			}
			if (GUIUtility.keyboardControl == 0)
			{
				GUIUtility.keyboardControl = controlID;
			}
			string text2 = EditorGUI.DoTextField(PopupList.s_RecycledEditor, controlID, rect, text, PopupList.s_Styles.customTextField, null, out flag5, false, false, false);
			Rect position = rect;
			position.x += rect.width;
			position.width = 14f;
			if ((GUI.Button(position, GUIContent.none, (!(text2 != string.Empty)) ? PopupList.s_Styles.customTextFieldCancelButtonEmpty : PopupList.s_Styles.customTextFieldCancelButton) && text2 != string.Empty) || flag4)
			{
				string empty = string.Empty;
				PopupList.s_RecycledEditor.content.text = empty;
				text2 = (EditorGUI.s_OriginalText = empty);
				PopupList.s_RecycledEditor.pos = 0;
				PopupList.s_RecycledEditor.selectPos = 0;
				flag = false;
			}
			if (text != text2)
			{
				this.m_EnteredText = ((0 > PopupList.s_RecycledEditor.pos || PopupList.s_RecycledEditor.pos >= text2.Length) ? text2 : text2.Substring(0, PopupList.s_RecycledEditor.pos));
				if (flag)
				{
					this.UpdateCompletion();
				}
				else
				{
					this.SelectNoCompletion();
				}
			}
			if (flag2)
			{
				editorWindow.Close();
			}
		}
예제 #8
0
		private void DrawList(EditorWindow editorWindow, Rect windowRect)
		{
			Event current = Event.current;
			int num = -1;
			foreach (PopupList.ListElement current2 in this.m_Data.GetFilteredList(this.m_EnteredText))
			{
				num++;
				Rect position = new Rect(0f, 10f + (float)num * 16f + ((this.m_Gravity != PopupList.Gravity.Top || !this.m_Data.m_AllowCustom) ? 0f : 16f), windowRect.width, 16f);
				EventType type = current.type;
				switch (type)
				{
				case EventType.MouseDown:
					if (Event.current.button == 0 && position.Contains(Event.current.mousePosition))
					{
						if (this.m_Data.m_OnSelectCallback != null)
						{
							this.m_Data.m_OnSelectCallback(current2);
						}
						current.Use();
						if (this.m_Data.m_CloseOnSelection)
						{
							editorWindow.Close();
						}
					}
					continue;
				case EventType.MouseUp:
				{
					IL_9B:
					if (type != EventType.Repaint)
					{
						continue;
					}
					GUIStyle gUIStyle = (!current2.partiallySelected) ? PopupList.s_Styles.menuItem : PopupList.s_Styles.menuItemMixed;
					bool flag = current2.selected || current2.partiallySelected;
					bool hasKeyboardFocus = false;
					bool isHover = num == this.m_SelectedCompletionIndex;
					bool isActive = flag;
					GUIContent content = current2.m_Content;
					gUIStyle.Draw(position, content, isHover, isActive, flag, hasKeyboardFocus);
					continue;
				}
				case EventType.MouseMove:
					if (position.Contains(Event.current.mousePosition))
					{
						this.SelectCompletionWithIndex(num);
						current.Use();
					}
					continue;
				}
				goto IL_9B;
			}
		}
예제 #9
0
 private void DrawCustomTextField(EditorWindow editorWindow, Rect windowRect)
 {
   if (!this.m_Data.m_AllowCustom)
     return;
   Event current = Event.current;
   bool flag1 = this.m_Data.m_EnableAutoCompletion;
   bool flag2 = false;
   bool flag3 = false;
   bool flag4 = false;
   string str1 = this.CurrentDisplayedText();
   if (current.type == EventType.KeyDown)
   {
     KeyCode keyCode = current.keyCode;
     switch (keyCode)
     {
       case KeyCode.Backspace:
         flag1 = false;
         break;
       case KeyCode.Tab:
       case KeyCode.Return:
         if (str1 != string.Empty)
         {
           if (this.m_Data.m_OnSelectCallback != null)
             this.m_Data.m_OnSelectCallback(this.m_Data.NewOrMatchingElement(str1));
           if (current.keyCode == KeyCode.Tab || current.keyCode == KeyCode.Comma)
             flag4 = true;
           if (this.m_Data.m_CloseOnSelection || current.keyCode == KeyCode.Return)
             flag2 = true;
         }
         flag3 = true;
         break;
       default:
         if (keyCode != KeyCode.UpArrow)
         {
           if (keyCode != KeyCode.DownArrow)
           {
             if (keyCode != KeyCode.None)
             {
               if (keyCode != KeyCode.Space && keyCode != KeyCode.Comma)
               {
                 if (keyCode == KeyCode.Delete)
                   goto case KeyCode.Backspace;
                 else
                   break;
               }
               else
                 goto case KeyCode.Tab;
             }
             else
             {
               if ((int) current.character == 32 || (int) current.character == 44)
               {
                 flag3 = true;
                 break;
               }
               break;
             }
           }
           else
           {
             this.ChangeSelectedCompletion(1);
             flag3 = true;
             break;
           }
         }
         else
         {
           this.ChangeSelectedCompletion(-1);
           flag3 = true;
           break;
         }
     }
   }
   bool changed = false;
   Rect position1 = new Rect(windowRect.x + 5f, windowRect.y + (this.m_Gravity != PopupList.Gravity.Top ? (float) ((double) windowRect.height - 16.0 - 5.0) : 5f), (float) ((double) windowRect.width - 10.0 - 14.0), 16f);
   GUI.SetNextControlName(PopupList.s_TextFieldName);
   EditorGUI.FocusTextInControl(PopupList.s_TextFieldName);
   int controlId = GUIUtility.GetControlID(PopupList.s_TextFieldHash, FocusType.Keyboard, position1);
   if (flag3)
     current.Use();
   if (GUIUtility.keyboardControl == 0)
     GUIUtility.keyboardControl = controlId;
   string str2 = EditorGUI.DoTextField(PopupList.s_RecycledEditor, controlId, position1, str1, PopupList.s_Styles.customTextField, (string) null, out changed, false, false, false);
   Rect position2 = position1;
   position2.x += position1.width;
   position2.width = 14f;
   if (GUI.Button(position2, GUIContent.none, !(str2 != string.Empty) ? PopupList.s_Styles.customTextFieldCancelButtonEmpty : PopupList.s_Styles.customTextFieldCancelButton) && str2 != string.Empty || flag4)
   {
     string empty = string.Empty;
     PopupList.s_RecycledEditor.text = empty;
     str2 = EditorGUI.s_OriginalText = empty;
     PopupList.s_RecycledEditor.cursorIndex = 0;
     PopupList.s_RecycledEditor.selectIndex = 0;
     flag1 = false;
   }
   if (str1 != str2)
   {
     this.m_EnteredText = 0 > PopupList.s_RecycledEditor.cursorIndex || PopupList.s_RecycledEditor.cursorIndex >= str2.Length ? str2 : str2.Substring(0, PopupList.s_RecycledEditor.cursorIndex);
     if (flag1)
       this.UpdateCompletion();
     else
       this.SelectNoCompletion();
   }
   if (!flag2)
     return;
   editorWindow.Close();
 }
예제 #10
0
 private void DrawList(EditorWindow editorWindow, Rect windowRect)
 {
   Event current = Event.current;
   int index = -1;
   foreach (PopupList.ListElement filtered in this.m_Data.GetFilteredList(this.m_EnteredText))
   {
     ++index;
     Rect position = new Rect(windowRect.x, (float) ((double) windowRect.y + 10.0 + (double) index * 16.0 + (this.m_Gravity != PopupList.Gravity.Top || !this.m_Data.m_AllowCustom ? 0.0 : 16.0)), windowRect.width, 16f);
     EventType type = current.type;
     switch (type)
     {
       case EventType.MouseDown:
         if (Event.current.button == 0 && position.Contains(Event.current.mousePosition) && filtered.enabled)
         {
           if (this.m_Data.m_OnSelectCallback != null)
             this.m_Data.m_OnSelectCallback(filtered);
           current.Use();
           if (this.m_Data.m_CloseOnSelection)
           {
             editorWindow.Close();
             continue;
           }
           continue;
         }
         continue;
       case EventType.MouseMove:
         if (position.Contains(Event.current.mousePosition))
         {
           this.SelectCompletionWithIndex(index);
           current.Use();
           continue;
         }
         continue;
       default:
         if (type == EventType.Repaint)
         {
           GUIStyle guiStyle = !filtered.partiallySelected ? PopupList.s_Styles.menuItem : PopupList.s_Styles.menuItemMixed;
           bool on = filtered.selected || filtered.partiallySelected;
           bool hasKeyboardFocus = false;
           bool isHover = index == this.m_SelectedCompletionIndex;
           bool isActive = on;
           EditorGUI.BeginDisabledGroup(!filtered.enabled);
           GUIContent content = filtered.m_Content;
           guiStyle.Draw(position, content, isHover, isActive, on, hasKeyboardFocus);
           EditorGUI.EndDisabledGroup();
           continue;
         }
         continue;
     }
   }
 }
예제 #11
0
        void Setup()
        {
            string[] scenes = System.IO.Directory.GetFiles(".", "*.unity", System.IO.SearchOption.AllDirectories);

            if (selectedPackage == Packages.UnityNetworking)
            {
                NetworkManagerCustom           netManager   = (NetworkManagerCustom)AssetDatabase.LoadAssetAtPath("Assets/TanksMultiplayer/Prefabs/Network.prefab", typeof(NetworkManagerCustom));
                System.Reflection.PropertyInfo playerPrefab = netManager.GetType().GetProperty("playerPrefab");
                playerPrefab.SetValue(netManager, Resources.Load("TankFree"), null);
                AssetDatabase.ImportAsset("Assets/TanksMultiplayer/Scripts/GameManager.cs");
            }

            if (selectedPackage == Packages.PhotonPUN)
            {
                #if !PUN_2_OR_NEWER
                Debug.LogError("Tanks Multiplayer - Network Setup: Could not find PhotonViewHandler. Did you import Photon yet?");
                #else
                EditorWindow photonWin = Photon.Pun.PhotonViewHandler.GetWindowWithRect(typeof(Photon.Pun.PhotonViewHandler), new Rect(0, 0, 0, 0));
                System.Reflection.MethodInfo hierarchyMethod = photonWin.GetType().GetMethod("HierarchyChange", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.DeclaredOnly);

                //automatic assignment of PhotonView IDs in non-loaded scenes
                foreach (string scene in scenes)
                {
                    if (scene.EndsWith("Game.unity"))
                    {
                        EditorSceneManager.OpenScene(scene);

                        //we have to disconnect all prefab connections first, because otherwise they can't be manipulated
                        //in the PhotonViewHandler.HierarchyChange method - seems like a Unity bug
                        ObjectSpawner[] objects = FindObjectsOfType(typeof(ObjectSpawner)) as ObjectSpawner[];
                        if (objects == null || objects.Length == 0)
                        {
                            continue;
                        }

                        for (int i = 0; i < objects.Length; i++)
                        {
                            if (PrefabUtility.IsPartOfPrefabInstance(objects[i]))
                            {
                                PrefabUtility.UnpackPrefabInstance(objects[i].gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
                            }
                        }

                        hierarchyMethod.Invoke(photonWin, null);
                        EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene(), EditorSceneManager.GetActiveScene().path);
                    }
                }

                photonWin.Close();
                #endif
            }

            foreach (string scene in scenes)
            {
                if (scene.EndsWith("Intro.unity"))
                {
                    EditorSceneManager.OpenScene(scene);
                    break;
                }
            }

            Debug.Log("Tanks Multiplayer - Setup Done!");
        }
예제 #12
0
            public static void ToggleWindow()
            {
                Type         gameViewType = typeof(Editor).Assembly.GetType("UnityEditor.GameView");
                bool         isMac        = Application.platform == RuntimePlatform.OSXEditor;
                EditorWindow gameView     = EditorWindow.GetWindow(gameViewType, !isMac, "Game");

                if (windowOpen)
                {
                    gameView.Close();
                    windowOpen = false;
                    return;
                }

                // ? this is gonna cause lots of problems if there is no Config
                LoadSettings();

                // necessary to close and reopen
                gameView.Close();
                gameView = EditorWindow.GetWindow(gameViewType, !isMac, "Game");
                int tabSize = 22 - 5; //this makes sense i promise

                // ? make it so toggling the preview from a 2nd display lentil will show THAT one
                gameView.maxSize  = new Vector2(Config.Instance.screenW, Config.Instance.screenH + tabSize);
                gameView.minSize  = gameView.maxSize;
                gameView.position = new Rect(position.x, position.y - tabSize, gameView.maxSize.x, gameView.maxSize.y);
                gameView.ShowPopup();
                PropertyInfo selectedSizeIndexProp = gameViewType.GetProperty
                                                     (
                    "selectedSizeIndex",
                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
                                                     );
                // Debug.Log(selectedSizeIndexProp.GetValue(gameView, null));
                Type sizesType    = typeof(Editor).Assembly.GetType("UnityEditor.GameViewSizes");
                var  singleType   = typeof(ScriptableSingleton <>).MakeGenericType(sizesType);
                var  instanceProp = singleType.GetProperty("instance");

                getGroup = sizesType.GetMethod("GetGroup");
                gameViewSizesInstance = instanceProp.GetValue(null, null);
                var group = GetGroup(GetCurrentGroupType());

                var getDisplayTexts = group.GetType().GetMethod("GetDisplayTexts");
                var displayTexts    = (string[])getDisplayTexts.Invoke(group, null);
                int index           = 0;

                for (int i = 0; i < displayTexts.Length; i++)
                {
                    if (displayTexts[i].Contains("Standalone"))
                    {
                        index = i;
                        break;
                    }
                }
                if (index == 0)
                {
                    Debug.LogWarning(Misc.debugLogText + "couldn't find standalone resolution in preview window");
                }

                selectedSizeIndexProp.SetValue(gameView, index, null);
                updateCount = 0;
                windowOpen  = true;
                EditorApplication.update += DelayedStuff;
            }
예제 #13
0
 public void GlobalTeardown()
 {
     m_Window.Close();
 }
        protected override TreeViewItem BuildRoot()
        {
            var root = new TreeViewItem(-1, -1, "Root");

            root.children = new List <TreeViewItem>();

            if (targets != null && targets.Length == 1)
            {
                var target = targets[0];

                if (target == null)
                {
                    parentWindow.Close();

                    return(root);
                }

                // Build the minimal transform hierarchy
                var parents = new List <GameObject>();

                var currentParent = target;

                while (currentParent != null)
                {
                    parents.Add(currentParent);
                    currentParent = currentParent.transform.parent.AsUnityNull()?.gameObject;
                }

                parents.Reverse();

                var rootTransform = parents[0];
                var scene         = rootTransform.gameObject.scene;
                var sceneItem     = new SceneItem(scene);
                root.AddChild(sceneItem);
                Item currentParentItem = sceneItem;

                foreach (var parent in parents)
                {
                    var parentItem = new GameObjectItem(parent);
                    currentParentItem.AddChild(parentItem);
                    currentParentItem = parentItem;
                }

                AddChildrenRecursive((GameObjectItem)currentParentItem);

                // AddSiblings((GameObjectItem)currentParentItem);
            }
            else
            {
                var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();

                if (prefabStage != null)
                {
                    // Build the prefab stage hierarchy

                    var prefabRoot     = prefabStage.prefabContentsRoot;
                    var prefabRootItem = new GameObjectItem(prefabRoot);

                    var stageItem = new PrefabStageItem(prefabStage);
                    AddChildrenRecursive(prefabRootItem);
                    stageItem.AddChild(prefabRootItem);
                    root.AddChild(stageItem);
                }
                else
                {
                    // Build the full scene hierarchy

                    for (var i = 0; i < SceneManager.sceneCount; i++)
                    {
                        var scene = SceneManager.GetSceneAt(i);

                        if (!scene.IsValid())
                        {
                            continue;
                        }

                        var sceneItem = new SceneItem(scene);

                        if (scene.isLoaded)
                        {
                            foreach (var sceneRootGameObject in scene.GetRootGameObjects())
                            {
                                var sceneRootGameObjectItem = new GameObjectItem(sceneRootGameObject);

                                AddChildrenRecursive(sceneRootGameObjectItem);

                                sceneItem.AddChild(sceneRootGameObjectItem);
                            }
                        }

                        root.AddChild(sceneItem);
                    }
                }
            }

            // Override with search if needed
            if (hasSearch)
            {
                var searchRoot    = new TreeViewItem(-1, -1, "Results");
                var searchResults = new List <TreeViewItem>();

                var treeViewItemStack = new Stack <TreeViewItem>();
                treeViewItemStack.Push(root);

                while (treeViewItemStack.Count > 0)
                {
                    var treeViewItem = treeViewItemStack.Pop();

                    if (treeViewItem.children != null)
                    {
                        foreach (var child in treeViewItem.children)
                        {
                            if (child != null)
                            {
                                if (DoesItemMatchSearch(child, searchString))
                                {
                                    searchResults.Add(child);
                                }

                                treeViewItemStack.Push(child);
                            }
                        }
                    }
                }

                foreach (var searchResult in searchResults)
                {
                    searchResult.children = null;
                }

                searchResults.Sort((x, y) => SearchUtility.Relevance(searchString, x.displayName).CompareTo(SearchUtility.Relevance(searchString, y.displayName)));
                searchRoot.children = searchResults;
                root = searchRoot;
            }

            SetupDepthsFromParentsAndChildren(root);

            hoveredItem = null;

            return(root);
        }
 public override void Close(ToolControl control)
 {
     window?.Close();
 }
        public void Editor()
        {
            // open, do nothing, close
            EditorWindow editor = new EditorWindow();
            editor.Show();
            this.WaitForRenderingComplete();
            editor.Close();

            // open, create template database, close
            string templateDatabaseFilePath = this.GetUniqueFilePathForTest(TestConstant.File.DefaultNewTemplateDatabaseFileName);
            if (File.Exists(templateDatabaseFilePath))
            {
                File.Delete(templateDatabaseFilePath);
            }
            editor = new EditorWindow();
            PrivateObject editorAccessor = new PrivateObject(editor);
            editor.Show();
            this.WaitForRenderingComplete();
            editorAccessor.Invoke(TestConstant.InitializeDataGridMethodName, templateDatabaseFilePath);
            this.WaitForRenderingComplete();
            editor.Close();

            // open, load existing database, pop dialogs, close
            // InitializeDataGrid() sets the template pane active but without the explicit set in test code the event gets dropped, resulting the EditChoiceList
            // show failing because the UIElement its position is referenced to is not visible.
            editor = new EditorWindow();
            editor.Show();
            this.WaitForRenderingComplete();
            editorAccessor.Invoke(TestConstant.InitializeDataGridMethodName, templateDatabaseFilePath);
            this.WaitForRenderingComplete();

            editor.TemplatePane.IsActive = true;
            this.WaitForRenderingComplete();

            this.ShowDialog(new AboutEditor(editor));
            this.ShowDialog(new EditChoiceList(editor.TemplateDataGrid, new List<string>() { "Choice0", "Choice1", "Choice2", "Choice3" }, editor));

            editor.Close();
        }
    public override void OnInspectorGUI()
    {
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Player id " + player.id);
        player.playerName = EditorGUILayout.TextField("Player Name ", player.playerName);


        EditorGUILayout.LabelField("Back Story");
        player.littleBackStory = EditorGUILayout.TextArea(player.littleBackStory, GUILayout.MinHeight(70));

        if (player.health < 20)
        {
            GUI.color = Color.red;
        }
        if (player.health > 80)
        {
            GUI.color = Color.green;
        }
        // below this will change color to red or green
        //player.health = EditorGUILayout.FloatField("Health", player.health);

        // Cool Rect ProgressBar
        Rect progressRect = GUILayoutUtility.GetRect(50, 50);

        EditorGUI.ProgressBar(progressRect, player.health / 100.0f, "Health");

        GUI.color = Color.white;

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        player.damage = EditorGUILayout.Slider("Damage ", player.damage, 10, 20);

        if (player.damage < 12)
        {
            EditorGUILayout.HelpBox("The damage is too low !", MessageType.Warning);
        }

        if (player.damage > 18)
        {
            EditorGUILayout.HelpBox("The damage is too high !", MessageType.Warning);
        }


        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        showWeapons = EditorGUILayout.Foldout(showWeapons, "Weapons");

        if (showWeapons)
        {
            EditorGUI.indentLevel += 2; // indentLevel
            player.weapon1Damage   = EditorGUILayout.FloatField("Weapon 1 Damage ", player.weapon1Damage);
            player.weapon2Damage   = EditorGUILayout.FloatField("Weapon 2 Damage ", player.weapon2Damage);
            EditorGUI.indentLevel -= 2; // indentLevel
        }

        EditorGUILayout.LabelField("Shoe");

        //EditorGUILayout.BeginHorizontal();
        //EditorGUILayout.LabelField("Name ", GUILayout.MaxWidth(40));
        //player.shoeName = EditorGUILayout.TextField(player.shoeName);
        //EditorGUILayout.LabelField("Size ", GUILayout.MaxWidth(40));
        //player.shoeSize = EditorGUILayout.IntField(player.shoeSize);
        //EditorGUILayout.LabelField("Type ", GUILayout.MaxWidth(40));
        //player.shoeType = EditorGUILayout.TextField(player.shoeType);
        //EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        #region Random Name
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Random Name"))
        {
            player.ButtonCallFromInspector();
        }
        if (GUILayout.Button("Random Name"))
        {
            player.ButtonCallFromInspector();
        }
        EditorGUILayout.EndHorizontal();
        #endregion
        #region Window
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Create Window"))
        {
            //MyFirstEditorWindow.ShowWindow();
            window = MyFirstEditorWindow.ShowWindow2();
        }
        if (GUILayout.Button("Close Window"))
        {
            window.Close();
        }
        EditorGUILayout.EndHorizontal();
        #endregion

        EditorGUILayout.EndVertical();

        player.health += 2;
        if (player.health > 100)
        {
            player.health = 0;
        }
    }
    static Rect modelNormalAndTangentRect; //预设脚本以及音效对象

    void Init()
    {
        if (string.IsNullOrEmpty(modelDvPath))
        {
            modelDvPath = @"Assets\Resources";
        }
        if (string.IsNullOrEmpty(modelNormalAndTangentPath))
        {
            modelNormalAndTangentPath = @"Assets\Resources";
        }
        if (GUILayout.Button("贴图工具", GUILayout.Height(35f)))
        {
            window.Close();
            Indra.TextureTool.TextureListWindow.OpenTexWindow();
        }
        if (GUILayout.Button("刷新模型顶部到底部的顶点色", GUILayout.Height(35)))
        {
            CharacterGlintVertexColorTool.Open();
        }

        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

        GUILayout.Label("移除模型法线和切线信息");
        GUILayout.BeginHorizontal();
        GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:");
        modelDvRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true));
        GUI.TextField(modelDvRect, modelDvPath);
        if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30)))
        {
            modelDvPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty);
        }
        GUILayout.EndHorizontal();
        if (GUILayout.Button("移除模型法线和切线信息"))
        {
            if (!string.IsNullOrEmpty(modelDvPath))
            {
                string cPath = ConversionPath(modelDvPath);
                if (string.IsNullOrEmpty(cPath))
                {
                    return;
                }
                string[] prefabs = AssetDatabase.FindAssets("t:model", new string[] { cPath });
                FbxSimplify.RemoveNormalAndTangent(prefabs);
            }
            else
            {
                EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK");
            }
        }

        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

        GUILayout.Label("禁用模型读写");
        GUILayout.BeginHorizontal();
        GUI.Label(GUILayoutUtility.GetRect(0, 20f, GUILayout.Width(100)), "当前路径:");
        modelNormalAndTangentRect = GUILayoutUtility.GetRect(0, 22f, GUILayout.ExpandWidth(true));
        GUI.TextField(modelNormalAndTangentRect, modelNormalAndTangentPath);
        if (GUILayout.Button("选择路径", GUILayout.Width(100), GUILayout.Height(30)))
        {
            modelNormalAndTangentPath = EditorUtility.OpenFolderPanel("选择需要检查的文件路径", string.Empty, string.Empty);
        }
        GUILayout.EndHorizontal();
        if (GUILayout.Button("禁用模型读写"))
        {
            if (!string.IsNullOrEmpty(modelNormalAndTangentPath))
            {
                string cPath = ConversionPath(modelNormalAndTangentPath);
                if (string.IsNullOrEmpty(cPath))
                {
                    return;
                }
                string[] prefabs = AssetDatabase.FindAssets("t:model", new string[] { cPath });
                FbxSimplify.RemoveTangents(prefabs);
            }
            else
            {
                EditorUtility.DisplayDialog("提醒", "路径为空!请选择你需要检查的路径!", "OK");
            }
        }
    }
예제 #19
0
    void CloseWindow()
    {
        EditorWindow SetupWindow = EditorWindow.GetWindow(typeof(WwiseUpdateSettings));

        SetupWindow.Close();
    }
예제 #20
0
        void OnGUI()
        {
            if (!shouldDraw)
            {
                w.Close();
                return;
            }

            headerStyle                  = new GUIStyle(GUI.skin.label);
            headerStyle.fontSize         = 18;
            headerStyle.fontStyle        = FontStyle.Bold;
            headerStyle.alignment        = TextAnchor.MiddleLeft;
            headerStyle.fixedHeight      = headerTexture.height;
            headerStyle.normal.textColor = Color.white;
            headerStyle.font             = headerFont;

            style0                  = new GUIStyle(GUI.skin.label);
            style0.fontSize         = 10;
            style0.fontStyle        = FontStyle.Italic;
            style0.alignment        = TextAnchor.UpperLeft;
            style0.fixedHeight      = 40f;
            style0.normal.textColor = Color.cyan;

            btnStyle = new GUIStyle(GUI.skin.button);
            btnStyle.hover.background = btnStyle.normal.background;
            btnStyle.hover.textColor  = new Color(1f, 112 / 255f, 4 / 255f, 1f);
            btnStyle.fixedWidth       = 160;
            btnStyle.stretchWidth     = true;

            btnStyle2 = new GUIStyle(GUI.skin.button);
            btnStyle2.hover.background = btnStyle.normal.background;
            btnStyle2.hover.textColor  = new Color(1f, 112 / 255f, 4 / 255f, 1f);
            btnStyle2.fixedWidth       = 80;
            btnStyle2.stretchWidth     = true;

            GUIStyle currentStyle = new GUIStyle(GUI.skin.box);

            currentStyle.normal.background = EditorUtils.MakeTex(2, 2, new Color(1f, 112 / 255f, 4 / 255f, 1f));
            currentStyle.fixedHeight       = headerStyle.fixedHeight * 1.2f;


            // Header //
            EditorGUILayout.BeginHorizontal(currentStyle);
            Rect rect = GUILayoutUtility.GetRect(0f, 0f);

            rect.width  = headerTexture.width;
            rect.height = headerTexture.height;
            GUILayout.Space(rect.height);
            GUI.DrawTexture(rect, headerTexture);
            EditorGUILayout.LabelField("Submit Bug Report", headerStyle);
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.BeginVertical();

            // Title //
            EditorGUILayout.LabelField("Title");
            _report.title = EditorGUILayout.TextField(_report.title);
            GUILayout.Space(15f);

            // Description //
            EditorGUILayout.LabelField("Description");
            if (System.String.IsNullOrEmpty(_report.title))
            {
                _report.description = "1) What happened?:" + "\n\n\n\n" + "2) How reproduce it?:";
            }

            _report.description = EditorGUILayout.TextArea(_report.description, GUILayout.Height(150));
            GUILayout.Space(15f);

            // Enviroment //
            _report.enviromentID = EditorGUILayout.Popup("Where did it happen? ", _report.enviromentID, _enviromentValues);
            GUILayout.Space(15f);

            // Attachment //
            EditorGUILayout.BeginVertical();
            GUILayout.Label("Attach file");
            EditorGUILayout.BeginHorizontal("box");
            if (GUILayout.Button("Select file", EditorStyles.miniButton))
            {
                _report.attachPath = EditorUtility.OpenFilePanel("Select file", "", "*.*");
            }
            EditorGUILayout.LabelField("file://" + _report.attachPath);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            GUILayout.Space(15f);

            // Your Email //
            EditorGUILayout.LabelField("Your E-mail");
            _report.email = EditorGUILayout.TextField(_report.email);
            GUILayout.Space(15f);

            EditorGUILayout.LabelField("Your local info:");
            // Scans //
            _report.assetVersion = SettingsManager.getVersion();
            _report.unityVersion = Application.unityVersion;
            _report.isUnityPro   = Application.HasProLicense();
            _report.buildTarget  = EditorUserBuildSettings.activeBuildTarget.ToString();
            _report.currentOS    = SystemInfo.operatingSystem;

            msg  = "2DDL Version: " + _report.assetVersion + "\n";
            msg += "Unity Version: " + _report.unityVersion + "\n";
            msg += "Unity Pro?: " + _report.isUnityPro + "\n";
            msg += "Build Target: " + _report.buildTarget + "\n";
            msg += "Current OS: " + _report.currentOS;

            EditorGUILayout.HelpBox(msg, MessageType.None);


            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Cancel", btnStyle2))
            {
                w.Close();
            }

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Submit", btnStyle))
            {
                if (BugReportUtils.SendReport("2DDL Bug Report tool", _report.email, consolidateData(), "New Bug: " + _report.title, _report.attachPath))
                {
                    BugReportUtils.SendReportProof("2DDL Bug Report <Automatic response>", _report.email, consolidateData(), "Proof of report sent: " + _report.title, _report.attachPath);

                    EditorUtility.DisplayDialog("2DDL Bug Report", "Successful submitted! You will receive a response within 48 hours.", "Ok");

                    w.Close();
                }
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.EndVertical();
            EditorGUILayout.EndVertical();
        }
예제 #21
0
        private void OnGUI()
        {
            CheckDataStatus();
            if (!_isLoaded || !_nowOpenedWindow || _openedClipData == null)
            {
                return;
            }

            GUILayout.BeginVertical();
            for (var i = 0; i < _openedClipData.filePath.Count; i++)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField($"Element {i}", GUILayout.MaxWidth(75));

                _loadedClips[i] = EditorGUILayout.ObjectField(_loadedClips[i], typeof(AudioClip), false,
                                                              GUILayout.MinWidth(125), GUILayout.MaxWidth(200)) as AudioClip;

                if (_loadedClips[i])
                {
                    _openedClipData.filePath[i] = _loadedClips[i].name;
                    _openedClipData.volumes[i]  =
                        EditorGUILayout.Slider(_openedClipData.volumes[i], 0, 1, GUILayout.MinWidth(125));
                }

                if (GUILayout.Button("+", GUILayout.MaxWidth(25)))
                {
                    _openedClipData.Insert(i);
                    _loadedClips.Insert(i, null);
                }

                GUI.color = Color.red;
                if (GUILayout.Button("x", GUILayout.MaxWidth(25)))
                {
                    _openedClipData.RemoveAt(i);
                    _loadedClips.RemoveAt(i);
                }

                GUI.color = Color.white;
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("데이터 추가"))
            {
                _openedClipData.Add();
                _loadedClips.Add(null);
            }

            if (IsAbleToSave())
            {
                GUI.color = Color.green;
                if (GUILayout.Button("데이터 저장"))
                {
                    // Json파일 수정.
                    using (var jsonFile =
                               new StreamWriter(Application.dataPath + Constants.Framework.SoundJsonFileAssetPath))
                    {
                        jsonFile.WriteLine(JsonUtility.ToJson(_openedClipData));
                        jsonFile.Close();
                    }

                    // 스크립트 텍스트 수정.
                    using (var classFile =
                               new StreamWriter(Application.dataPath + Constants.Framework.SoundTypeFileAssetPath))
                    {
                        var enumData = _loadedClips.Aggregate(string.Empty,
                                                              (current, t) => current + $"\t{t.name},\n");

                        classFile.WriteLine(
                            string.Format(Constants.Framework.CsFileSummary, name) +
                            Constants.Framework.SoundTypeEnumClassDeclare + "\n{\n\t" + "None," + "\n" + enumData +
                            "}");
                        classFile.Close();
                    }

                    AssetDatabase.Refresh();
                    _nowOpenedWindow.Close();
                }

                GUI.color = Color.white;
            }

            GUILayout.EndVertical();
        }
예제 #22
0
    static void CloseGameWindow()
    {
        EditorWindow gameView = GetMainGameView();

        gameView.Close();
    }
예제 #23
0
        //目标平台
        private static bool BulidTarget(bool isDebug = false)
        {
            System.GC.Collect();
            System.GC.Collect();

            bool result = true;

            try
            {
                Debug.Log("开始预处理过程...");
                AssetDatabase.Refresh();

                // 场景
                EditorScenes();
                // 打包环境
                BuildEnv(isDebug);

                // 收集lua文件
                BuildLuaConfigs.Collect();

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                // 拷贝所有lua并加上txt后缀
                DirRemove(m_luaTempFolderPath);
                DirCopy(m_luaResourceFolderPath, m_luaTempFolderPath, ".txt");
#else
                // 拷贝所有lua并编译为bytecode
                DirRemove(m_luaTempFolderPath);
                GenLuaByteCode(m_luaResourceFolderPath, m_luaTempFolderPath);
#endif
                AssetDatabase.Refresh();

                Debug.Log("预处理过程结束...");

                // 开始Build,等待吧~
                if (m_buildTarget == BuildTarget.NoTarget)
                {
                    throw new Exception("未选择打包平台!!!");
                }
                EditorUserBuildSettings.SwitchActiveBuildTarget(m_buildTargetGroup, m_buildTarget);
                UnityEditor.Build.Reporting.BuildReport res = BuildPipeline.BuildPlayer(m_buildScenes, m_buildPath, m_buildTarget, m_buildOptions);
                if (res.summary.totalErrors > 0)
                {
                    throw new Exception("BuildPlayer failure: " + res);
                }
                else
                {
                    Debug.Log("生成版本成功!");
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("[BuildingStepError]: " + e);
                result = false;
                throw;
            }
            finally
            {
                Debug.Log("开始后处理过程...");

                // 删除临时文件夹
                DirRemove(m_luaTempFolderPath);
                // ScriptingBackend
                PlayerSettings.SetScriptingBackend(m_buildTargetGroup, ScriptingImplementation.IL2CPP);
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();

                Debug.Log("后处理过程结束...");
                Debug.Log("版本发布结束!");

                if (null != m_editorWindow)
                {
                    m_editorWindow.Close();
                }
            }
            System.GC.Collect();
            m_xluaGen  = false;
            m_buildApp = false;
            WriteBuildTxt();

            return(result);
        }
예제 #24
0
    void CloseWindow()
    {
        EditorWindow SetupWindow = EditorWindow.GetWindow(typeof(AkWwiseSettingsWindow));

        SetupWindow.Close();
    }
        static void ClosePrefabCenter()
        {
            EditorWindow window = GetWindow(typeof(PrefabCenter), false, "Prefab Center");

            window.Close();
        }
 private void CreateLibraryAndCloseWindow(EditorWindow editorWindow)
 {
   this.m_ErrorString = this.m_CreateLibraryCallback(this.m_NewLibraryName, PopupWindowContentForNewLibrary.s_Texts.fileLocationOrder[this.m_SelectedIndexInPopup]);
   if (!string.IsNullOrEmpty(this.m_ErrorString))
     return;
   editorWindow.Close();
 }
예제 #27
0
            void OnGUI()
            {
                if (background == null)
                {
                    background = new Texture2D(1, 1, TextureFormat.RGBA32, false);
                    background.SetPixel(0, 0, new Color(0.98f, 0.98f, 0.98f));
                    background.Apply();
                }

                if (highlight == null)
                {
                    highlight = new Texture2D(1, 1, TextureFormat.RGBA32, false);
                    highlight.SetPixel(0, 0, new Color(0.6f, 0.7f, 0.9f));
                    highlight.Apply();
                }

                Rect  fullRect   = new Rect(0, 0, this.position.width, this.position.height);
                float lineHeight = this.position.height / items.Length;

                //background
                if (Event.current.type == EventType.Repaint)
                {
                    GUI.skin.box.Draw(fullRect, false, true, true, false);
                }
                GUI.DrawTexture(new Rect(1, 1, fullRect.width - 2, fullRect.height - 2), background, ScaleMode.StretchToFill);

                //list
                for (int i = 0; i < items.Length; i++)
                {
                    MenuItem currentItem = items[i];

                    currentItem.clicked = false;
                    Rect lineRect    = new Rect(1, i * lineHeight + 1, fullRect.width - 2, lineHeight - 2);
                    bool highlighted = lineRect.Contains(Event.current.mousePosition);

                    if (highlighted)
                    {
                        GUI.DrawTexture(lineRect, highlight);
                    }

                    //labels
                    EditorGUI.LabelField(lineRect, currentItem.name);

                    if (currentItem.hasSubs)
                    {
                        char rightChar = '\u25B6';
                        Rect rightRect = lineRect; rightRect.width = 12; rightRect.x = lineRect.x + lineRect.width - rightRect.width;
                        EditorGUI.LabelField(rightRect, "" + rightChar);
                    }

                    //pressing
                    if (highlighted && Event.current.type == EventType.MouseDown && Event.current.type == 0)
                    {
                        currentItem.clicked = true;
                        this.Close();

                        if (currentItem.onClick != null)
                        {
                            currentItem.onClick();
                        }

                        EditorWindow.focusedWindow.Repaint();
                    }

                    //opening subsmenus
                    if (highlighted)
                    {
                        if (currentItem != lastItem)
                        {
                            lastTimestart = System.DateTime.Now;
                            timeUsed      = false;
                        }

                        if ((System.DateTime.Now - lastTimestart).TotalMilliseconds > 500 && !timeUsed)
                        {
                            //closing old expanded window
                            if (expandedWindow != null)
                            {
                                expandedWindow.Close();
                            }

                            //opening new one
                            if (currentItem.hasSubs)
                            {
                                expandedWindow = DrawPopup(currentItem.subItems, lineRect.max - new Vector2(0, lineHeight) + this.position.position);
                            }
                            else
                            {
                                this.Focus();                                 //returning focus to this menu
                            }
                            timeUsed = true;
                        }

                        lastItem = currentItem;
                    }
                }

                //selecting

                /*int selected = GUI.SelectionGrid(fullRect,-1,items,1,EditorStyles.label);
                 * if (selected != -1)
                 * {
                 *      System.Type genType = Generator.types[selected+1];
                 *      Generator newGen = (Generator)System.Activator.CreateInstance(genType);
                 *
                 *      Vector2 newGenPos = new Vector2(50-baseWindow.position.x+this.position.x, 10-baseWindow.position.y+this.position.y);
                 *      newGen.guiRect = baseWindow.ToWorldSpace( new Rect(newGenPos.x-Generator.guiRectWidth/2, newGenPos.y-20, Generator.guiRectWidth, 1) );
                 *
                 *      baseWindow.script.AddGenerator(newGen);
                 *
                 *      this.Close();
                 *      baseWindow.Repaint();
                 * }*/


                //if (GUI.Button(new Rect(10,10, 40, 20), "Close")) this.Close();
                if (Event.current.rawType == EventType.MouseUp)
                {
                    this.Close();
                }


                //if (EditorWindow.focusedWindow.GetType() != typeof(Menu)) this.Focus();
                this.Repaint();
            }