Ejemplo n.º 1
0
        private void ShowUnityRemoteGUI(bool editorEnabled)
        {
            GUI.enabled = true;
            GUILayout.Label("Unity Remote", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = editorEnabled;
            int        indexById1 = EditorSettingsInspector.GetIndexById(this.remoteDeviceList, EditorSettings.unityRemoteDevice, 0);
            GUIContent content1   = new GUIContent(this.remoteDevicePopupList[indexById1].content);
            Rect       rect1      = EditorGUI.PrefixLabel(GUILayoutUtility.GetRect(content1, EditorStyles.popup), 0, new GUIContent("Device"));

            if (EditorGUI.ButtonMouseDown(rect1, content1, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect1, this.remoteDevicePopupList, indexById1, new GenericMenu.MenuFunction2(this.SetUnityRemoteDevice));
            }
            int        indexById2 = EditorSettingsInspector.GetIndexById(this.remoteCompressionList, EditorSettings.unityRemoteCompression, 0);
            GUIContent content2   = new GUIContent(this.remoteCompressionList[indexById2].content);
            Rect       rect2      = EditorGUI.PrefixLabel(GUILayoutUtility.GetRect(content2, EditorStyles.popup), 0, new GUIContent("Compression"));

            if (EditorGUI.ButtonMouseDown(rect2, content2, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect2, this.remoteCompressionList, indexById2, new GenericMenu.MenuFunction2(this.SetUnityRemoteCompression));
            }
            int        indexById3 = EditorSettingsInspector.GetIndexById(this.remoteResolutionList, EditorSettings.unityRemoteResolution, 0);
            GUIContent content3   = new GUIContent(this.remoteResolutionList[indexById3].content);
            Rect       rect3      = EditorGUI.PrefixLabel(GUILayoutUtility.GetRect(content3, EditorStyles.popup), 0, new GUIContent("Resolution"));

            if (!EditorGUI.ButtonMouseDown(rect3, content3, FocusType.Passive, EditorStyles.popup))
            {
                return;
            }
            this.DoPopup(rect3, this.remoteResolutionList, indexById3, new GenericMenu.MenuFunction2(this.SetUnityRemoteResolution));
        }
Ejemplo n.º 2
0
        private static void CreatePopupMenuVersionControl(string title, EditorSettingsInspector.PopupElement[] elements, string selectedValue,
                                                          GenericMenu.MenuFunction2 func)
        {
            var selectedIndex =
                System.Array.FindIndex(elements, (EditorSettingsInspector.PopupElement typeElem) => (typeElem.id == selectedValue));
            var content = new GUIContent(elements[selectedIndex].content);

            EditorSettingsInspector.CreatePopupMenu(title, content, elements, selectedIndex, func);
        }
        private void CreatePopupMenuVersionControl(string title, EditorSettingsInspector.PopupElement[] elements, string selectedValue,
                                                   GenericMenu.MenuFunction2 func)
        {
            var selectedIndex = Array.FindIndex(elements, e => e.id == selectedValue);

            if (selectedIndex == -1)
            {
                selectedIndex = Array.FindIndex(elements, e => e.id == ExternalVersionControl.Generic);
            }
            var content = new GUIContent(elements[selectedIndex].content);

            EditorSettingsInspector.CreatePopupMenu(null, new GUIContent(title), content, elements, selectedIndex, func);
        }
Ejemplo n.º 4
0
        private void ShowUnityRemoteGUI(bool editorEnabled)
        {
            GUI.enabled = true;
            GUILayout.Label("Unity Remote", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUI.enabled = editorEnabled;
            string     unityRemoteDevice = EditorSettings.unityRemoteDevice;
            int        indexById         = EditorSettingsInspector.GetIndexById(this.remoteDeviceList, unityRemoteDevice, 0);
            GUIContent content           = new GUIContent(this.remoteDevicePopupList[indexById].content);
            Rect       rect = GUILayoutUtility.GetRect(content, EditorStyles.popup);

            rect = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Device"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.remoteDevicePopupList, indexById, new GenericMenu.MenuFunction2(this.SetUnityRemoteDevice));
            }
            int indexById2 = EditorSettingsInspector.GetIndexById(this.remoteCompressionList, EditorSettings.unityRemoteCompression, 0);

            content = new GUIContent(this.remoteCompressionList[indexById2].content);
            rect    = GUILayoutUtility.GetRect(content, EditorStyles.popup);
            rect    = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Compression"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.remoteCompressionList, indexById2, new GenericMenu.MenuFunction2(this.SetUnityRemoteCompression));
            }
            int indexById3 = EditorSettingsInspector.GetIndexById(this.remoteResolutionList, EditorSettings.unityRemoteResolution, 0);

            content = new GUIContent(this.remoteResolutionList[indexById3].content);
            rect    = GUILayoutUtility.GetRect(content, EditorStyles.popup);
            rect    = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Resolution"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.remoteResolutionList, indexById3, new GenericMenu.MenuFunction2(this.SetUnityRemoteResolution));
            }
            int indexById4 = EditorSettingsInspector.GetIndexById(this.remoteJoystickSourceList, EditorSettings.unityRemoteJoystickSource, 0);

            content = new GUIContent(this.remoteJoystickSourceList[indexById4].content);
            rect    = GUILayoutUtility.GetRect(content, EditorStyles.popup);
            rect    = EditorGUI.PrefixLabel(rect, 0, new GUIContent("Joystick Source"));
            if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.popup))
            {
                this.DoPopup(rect, this.remoteJoystickSourceList, indexById4, new GenericMenu.MenuFunction2(this.SetUnityRemoteJoystickSource));
            }
        }
		private void DoPopup(Rect popupRect, EditorSettingsInspector.PopupElement[] elements, int selectedIndex, GenericMenu.MenuFunction2 func)
		{
			GenericMenu genericMenu = new GenericMenu();
			for (int i = 0; i < elements.Length; i++)
			{
				EditorSettingsInspector.PopupElement popupElement = elements[i];
				if (popupElement.Enabled)
				{
					genericMenu.AddItem(popupElement.content, i == selectedIndex, func, i);
				}
				else
				{
					genericMenu.AddDisabledItem(popupElement.content);
				}
			}
			genericMenu.DropDown(popupRect);
		}
		private static int GetIndexById(EditorSettingsInspector.PopupElement[] elements, string id, int defaultIndex)
		{
			for (int i = 0; i < elements.Length; i++)
			{
				if (elements[i].id == id)
				{
					return i;
				}
			}
			return defaultIndex;
		}
 private void DoPopup(Rect popupRect, EditorSettingsInspector.PopupElement[] elements, int selectedIndex, GenericMenu.MenuFunction2 func)
 {
   GenericMenu genericMenu = new GenericMenu();
   for (int index = 0; index < elements.Length; ++index)
   {
     EditorSettingsInspector.PopupElement element = elements[index];
     if (element.Enabled)
       genericMenu.AddItem(element.content, index == selectedIndex, func, (object) index);
     else
       genericMenu.AddDisabledItem(element.content);
   }
   genericMenu.DropDown(popupRect);
 }
 private static int GetIndexById(EditorSettingsInspector.PopupElement[] elements, string id, int defaultIndex)
 {
   for (int index = 0; index < elements.Length; ++index)
   {
     if (elements[index].id == id)
       return index;
   }
   return defaultIndex;
 }