public static Popup ( |
||
label | Optional label in front of the field. | |
selectedIndex | int | The index of the option the field shows. |
displayedOptions | An array with the options shown in the popup. | |
return | int |
void FromStateFilterInspector(TransitionProfile profile, FromStateFilter filter, ref Rect stateRect) { EGL.BeginHorizontal(); filter.type = (FromStateType)EGL.EnumPopup(filter.type, GL.Width(70)); if (filter.type == FromStateType.State) { EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, allStateNames, str => filter.stateOrTagName = str, ref stateRect); } else if (filter.type == FromStateType.Tag) { EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, transition.profile.tags, str => filter.stateOrTagName = str, ref stateRect); } if (filter.type == FromStateType.State) { var state = transition.profile.FindState(filter.stateOrTagName); if (state == null) { EGL.EndHorizontal(); EGL.HelpBox("No Source State", MessageType.Error); } else { List <string> portionSelections = new List <string>(); portionSelections.Add("<any>"); foreach (var p in state.allPortions) { portionSelections.Add(p.name); } var prevIndex = portionSelections.IndexOf(filter.portionName); if (prevIndex == -1) { prevIndex = 0; } prevIndex = EGL.Popup(prevIndex, portionSelections.ToArray()); filter.portionName = prevIndex == 0 ? "" : portionSelections[prevIndex]; if (GL.Button("Focus")) { Utils.FocusEditingAnimation(profile, state.stateName); } EGL.EndHorizontal(); } } else { EGL.EndHorizontal(); } }
void DrawInsertDropdown(SP dialog, int cursorIndex, TextEditor textEditor, string name, List <string> ids, string insertButtonText, string pattern, Func <int> getSelectedIndex, Action <int> setSelectedIndex) { if (ids == null || ids.Count < 1) { return; } EGL.BeginHorizontal(ES.helpBox); float insertButtonWidth = insertButtonText.Length * CharacterPixelWidth; if (GUILayout.Button(insertButtonText, ES.miniButton, GUILayout.MinWidth(insertButtonWidth), GUILayout.ExpandHeight(true))) { string id = ids[getSelectedIndex()]; string insertText = pattern + "Id = " + id + ">"; dialog.stringValue = dialog.stringValue.Insert(cursorIndex, insertText); Debug.Log(string.Format("Inserted {0} into content at index: {1}", insertText, cursorIndex)); } string[] displayIdsText = ids.Select(id => id = "Id: " + id).ToArray(); float maxPopupWidth = displayIdsText[getSelectedIndex()].Length * CharacterPixelWidth; GUIStyle popupStyle = new GUIStyle(ES.popup) { alignment = TextAnchor.MiddleCenter }; GUI.SetNextControlName(name); int index = EGL.Popup( getSelectedIndex(), displayIdsText, popupStyle, GUILayout.MinWidth(maxPopupWidth), GUILayout.MinHeight(GUILayoutUtility.GetLastRect().height) ); setSelectedIndex(index); EGL.EndHorizontal(); }
public override void OnInspectorGUI() { var settings = (ImportSettings)target; Undo.RecordObject(settings, "AseFileSettings"); using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Options"); } settings.generatePrefab = EGL.Toggle("Generate Prefab", settings.generatePrefab); settings.ppu = EGL.IntField("Pixel Per Unit", settings.ppu); settings.alignment = (SpriteAlignment)EGL.EnumPopup("Default Align", settings.alignment); if (settings.alignment == SpriteAlignment.Custom) { settings.customPivot = EGL.Vector2Field("Custom Pivot", settings.customPivot); } settings.densePacked = EGL.Toggle("Dense Pack", settings.densePacked); settings.border = EGL.IntField("Border", settings.border); EGL.Space(); if (settings.generatePrefab) { using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Prefab Options"); } EGL.BeginHorizontal(); string[] opetions = SortingLayer.layers.Select(it => it.name).ToArray(); settings.sortIndex = EGL.Popup("Sort In Layer", settings.sortIndex, opetions); settings.spritesSortInLayer = SortingLayer.NameToID(opetions[settings.sortIndex]); if (GL.Button("Edit", GL.Width(36))) { Selection.objects = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset"); } EGL.EndHorizontal(); settings.orderInLayerInterval = EGL.IntField("Interval of order in layer", settings.orderInLayerInterval); } EGL.Space(); using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Output"); } settings.atlasOutputDirectory = PathSelection("Atlas Directory", settings.atlasOutputDirectory); settings.clipOutputDirectory = PathSelection("Anim Clip Directory", settings.clipOutputDirectory); settings.controllerPolicy = (AnimControllerOutputPolicy)EGL.EnumPopup("Anim Controller Policy", settings.controllerPolicy); if (settings.controllerPolicy == AnimControllerOutputPolicy.CreateOrOverride || settings.controllerPolicy == AnimControllerOutputPolicy.CreateNotOverride) { settings.animControllerOutputPath = PathSelection("Anim Controller Directory", settings.animControllerOutputPath); } if (settings.generatePrefab) { settings.prefabsDirectory = PathSelection("Prefab Directory", settings.prefabsDirectory); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var pb = (LayerPresetLoader)target; if (isGettingLayers) { EGL.Space(); EGL.Space(); EGL.LabelField("Loading Layers..."); return; } if (layersList.Count == 0) { isGettingLayers = true; LayerLoader.Init(); new Thread(GetLayersList).Start(); } EGL.Space(); EGL.Space(); EGL.LabelField("Presets"); EGL.Space(); for (int i = 0; i < pb.presets.Count; i++) { using (new HorizontalGroup()) { pb.presets[i].presetName = EGL.TextField( string.IsNullOrEmpty(pb.presets[i].presetName) ? "Preset " + (i + 1) : pb.presets[i].presetName, pb.presets[i].presetName); if (GUILayout.Button("X")) { pb.presets[i] = null; pb.presets.RemoveAt(i); return; } } EditorGUI.indentLevel++; EGL.LabelField("Flat Layers"); EditorGUI.indentLevel++; filter = EGL.TextField("shared layer filter", filter); var filteredList = new List <string>(layersList); var preset = pb.presets[i]; for (int j = 0; j < pb.presets[i].layersInPreset.Count; j++) { using (new HorizontalGroup()) { if (layersList.Contains(pb.presets[i].layersInPreset[j])) { if (!string.IsNullOrEmpty(filter)) { filteredList = layersList.Where(entry => entry.ToLower().Contains(filter.ToLower()) || entry == pb.presets[i].layersInPreset[j]).ToList(); } pb.presets[i].layersInPreset[j] = filteredList[ EGL.Popup(j == 0 ? "Base Layer" : "Layer", filteredList.IndexOf(preset.layersInPreset[j]), filteredList.ToArray())]; } else { return; } if (GUILayout.Button("X")) { pb.presets[i].RemoveLayer(j); return; } } } if (pb.presets[i].layersInPreset.Count < 3) { using (new HorizontalGroup()) { //var nLayer = layersList[EGL.Popup("Layer", 0, layersList.ToArray())]; EGL.LabelField("New Overlay Layer"); if (GUILayout.Button("+")) { pb.presets[i].AddOverlayLayer(layersList[0]); break; } } } EditorGUI.indentLevel--; EGL.LabelField("Volumetric Layers"); EditorGUI.indentLevel++; for (int j = 0; j < pb.presets[i].volumetricLayers.Count; j++) { using (new HorizontalGroup()) { if (!string.IsNullOrEmpty(pb.presets[i].volumetricLayers[j])) { if (layersList.Contains(pb.presets[i].volumetricLayers[j])) { if (!string.IsNullOrEmpty(filter)) { filteredList = layersList.Where(entry => entry.ToLower().Contains(filter.ToLower()) || entry == pb.presets[i].volumetricLayers[j]).ToList(); } pb.presets[i].volumetricLayers[j] = filteredList[ EGL.Popup("Layer " + j, filteredList.IndexOf(preset.volumetricLayers[j]), filteredList.ToArray())]; } if (GUILayout.Button("X")) { pb.presets[i].volumetricLayers[j] = ""; } } else { if (GUILayout.Button("Activate")) { pb.presets[i].volumetricLayers[j] = "MODIS_Fires_All"; } } } } EditorGUI.indentLevel--; EditorGUI.indentLevel--; EGL.Space(); } using (new HorizontalGroup()) { if (GUILayout.Button("+")) { pb.presets.Add(new Preset()); } } if (GUI.changed) { Undo.RegisterCompleteObjectUndo(pb, "Preset change"); EditorUtility.SetDirty(pb); } }
public override void OnInspectorGUI() { transition = (Transition)target; EditorGUI.BeginChangeCheck(); var fromName = transition.fromState.GetStatePreview(); var toName = transition.targetInfo; var displayName = fromName + "->" + toName; EGL.LabelField(displayName); EGL.Space(); FromStateFilterInspector(transition.profile, transition.fromState, ref fromStateRect); EGL.Space(); transition.triggerRangeType = (TriggerRangeType)EGL.EnumPopup("Trigger Range Type", transition.triggerRangeType); if (transition.triggerRangeType == TriggerRangeType.Range) { transition.triggerRange = EditorGUIUtil.FrameRangeInput("Trigger Frame", transition.triggerRange); } if (transition.triggerRangeType == TriggerRangeType.FrameSinceExec || transition.triggerRangeType == TriggerRangeType.FrameSinceExecBefore) { transition.triggerFrameSinceExec = EGL.IntField("Frame Since Exec", transition.triggerFrameSinceExec); } transition.timeBuffer = EGL.FloatField("Time Buffer", transition.timeBuffer); using (new EGL.VerticalScope(EditorStyles.helpBox)) { var conds = transition.conditions; var paramNames = transition.profile.parameters.Select(it => it.name).ToArray(); using (new EGL.HorizontalScope()) { EGL.LabelField("Conditions", EditorStyles.boldLabel); GL.FlexibleSpace(); if (GL.Button("+", GL.Width(30))) { conds.Add(new Condition()); } } for (int i = 0; i < conds.Count; ++i) { var cond = conds[i]; EGL.BeginHorizontal(); int condSelectIndex = Mathf.Max(0, Array.IndexOf(paramNames, cond.name)); // cond.name = EGL.TextField(cond.name, GL.Width(70)); condSelectIndex = EGL.Popup(condSelectIndex, paramNames); cond.name = paramNames[condSelectIndex]; var param = transition.profile.FindParam(cond.name); if (param == null) { EGL.LabelField("!Doesn't exist"); } else { var type = param.type; if (type == ParamType.Bool) { cond.boolValue = EGL.Toggle(cond.boolValue); } else if (type != ParamType.Trigger) // Trigger 不需要编辑 { cond.cmp = (Cmp)EGL.EnumPopup(cond.cmp, GL.Width(50)); if (type == ParamType.Int) { cond.intValue = EGL.IntField(cond.intValue); } else { cond.floatValue = EGL.FloatField(cond.floatValue); } } } GL.FlexibleSpace(); if (GL.Button("-", GL.Width(30))) { conds.RemoveAt(i); --i; } EGL.EndHorizontal(); } } EGL.LabelField("", GUI.skin.horizontalSlider); transition.actionType = (ActionType)EGL.EnumPopup("Action", transition.actionType); if (transition.actionType == ActionType.ChangeState) { EGL.BeginHorizontal(); EGL.PrefixLabel("Target State"); EditorGUIUtil.AutoCompleteList(transition.targetStateName, allStateNames, str => transition.targetStateName = str, ref targetStateRect); transition.targetStateFrame = EGL.IntField(transition.targetStateFrame, GL.Width(30)); EGL.LabelField("F", GUILayout.Width(20)); var targetState = transition.profile.FindState(transition.targetStateName); if (targetState) { if (GL.Button("Focus")) { Utils.FocusEditingAnimation(transition.profile, targetState.stateName); } } EGL.EndHorizontal(); if (!targetState) { EGL.HelpBox("No target state " + targetState, MessageType.Error); } } else // SendMessage { transition.messageName = EGL.TextField("Message Name", transition.messageName); EGL.Space(); transition.messageParType = (MessageParType)EGL.EnumPopup("Parameter Type", transition.messageParType); switch (transition.messageParType) { case MessageParType.Int: transition.messageParInt = EGL.IntField("Value", transition.messageParInt); break; case MessageParType.Float: transition.messageParFloat = EGL.FloatField("Value", transition.messageParFloat); break; case MessageParType.Bool: transition.messageParBool = EGL.Toggle("Value", transition.messageParBool); break; } } transition.priority = EGL.IntField("Priority", transition.priority); transition.shouldDelay = EGL.Toggle("Should Delay", transition.shouldDelay); if (transition.shouldDelay) { transition.delay = EGL.FloatField("Delay", transition.delay); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(transition); } if (transition.fromState.type == FromStateType.State) { EGL.LabelField("", GUI.skin.horizontalSlider); using (new EGL.VerticalScope(EditorStyles.helpBox)) { EGL.LabelField("From State", EditorStyles.boldLabel); ++EditorGUI.indentLevel; var fromState = transition.profile.FindState(transition.fromState.stateOrTagName); if (fromState) { GUI.enabled = false; if (!fromStateEditor || fromStateEditor.target != fromState) { if (fromStateEditor) { DestroyImmediate(fromStateEditor); } fromStateEditor = Editor.CreateEditor(fromState); } fromStateEditor.OnInspectorGUI(); GUI.enabled = true; } --EditorGUI.indentLevel; } } }
private void OnGUI() { UG.BeginVertical(); UG.BeginHorizontal(); UG.LabelField("当前数据源:" + (_dataPath.IsNullPath() ? "未在本地保存,已编辑内容随时可能丢失!" : _dataPath)); if (GUILayout.Button("选择")) { string path = EditorUtility.OpenFilePanelWithFilters("选择数据源文件", Application.dataPath + "/Hotassets/Data", new [] { "text", "txt" }); if (!string.IsNullOrEmpty(path)) { Dictionary <string, List <InterlocutionData> > temperData = null; try { temperData = JsonConvert.DeserializeObject <Dictionary <string, List <InterlocutionData> > >(File.ReadAllText(path)); } catch (JsonException) { temperData = _data; path = _dataPath; EditorApplication.Beep(); EditorUtility.DisplayDialog("异常捕获!", "数据源文件不能被正确加载,请确定.json文件的有效性", "知道了"); } finally { _data = temperData; _dataPath = path; } } } UG.EndHorizontal(); UG.BeginHorizontal(); int subject = UG.Popup("所属学科", _editingSubject, InterlocutionData.Keys); if (subject != _editingSubject) { _editingInterlocution = -1; } _editingSubject = subject; string key = InterlocutionData.Keys[_editingSubject]; UG.LabelField("分组", _editingSubject != InterlocutionData.Keys.Length - 1 ? Subject.ToSubject(InterlocutionData.Keys[_editingSubject]).group.ToString() : "无"); UG.EndHorizontal(); _scrollPostion = UG.BeginScrollView(_scrollPostion); if (!_data.ContainsKey(key)) { _data[key] = new List <InterlocutionData>(); } List <InterlocutionData> interlocutions = _data[key]; int _deletedInterlocution = -1; UG.LabelField("[已有 " + interlocutions.Count + " 道问答]"); for (int i = 0, l = interlocutions.Count; i < l; i++) { UG.BeginHorizontal(); UG.LabelField("[Q " + i + "] " + interlocutions[i].question); if (GUILayout.Button("编辑")) { _editingInterlocution = i; } if (GUILayout.Button("删除")) { EditorApplication.Beep(); if (EditorUtility.DisplayDialog("危险操作警告⚠️", "即将删除问答 [Q" + i + "] (该操作不可逆)", "确认", "取消")) { _deletedInterlocution = i; if (_editingInterlocution == _deletedInterlocution) { _editingInterlocution = -1; } } } UG.EndHorizontal(); } if (_deletedInterlocution != -1) { interlocutions.RemoveAt(_deletedInterlocution); } UG.EndScrollView(); if (GUILayout.Button("添加问答")) { _editingInterlocution = interlocutions.Count; interlocutions.Add(new InterlocutionData()); } UG.LabelField("问答编辑区"); if (_editingInterlocution != -1) { UG.LabelField("Q " + _editingInterlocution); InterlocutionData interlocution = interlocutions[_editingInterlocution]; interlocution.question = UG.TextArea(interlocution.question); interlocution.answer = (Option)UG.EnumPopup("正确选项", interlocution.answer); UG.LabelField("选项A"); interlocution.optionA = UG.TextArea(interlocution.optionA); UG.LabelField("选项B"); interlocution.optionB = UG.TextArea(interlocution.optionB); UG.LabelField("选项C"); interlocution.optionC = UG.TextArea(interlocution.optionC); UG.LabelField("选项D"); interlocution.optionD = UG.TextArea(interlocution.optionD); } else { UG.HelpBox("需要选择一个问答进行编辑!", MessageType.Warning); } if (GUILayout.Button("保存")) { bool toSave = true; bool toImport = false; if (_dataPath.IsNullPath()) { string path = EditorUtility.SaveFilePanel("保存问答数据", Application.dataPath + "/Hotassets/Data", "InterlocutionData", "txt"); if (string.IsNullOrEmpty(path)) { toSave = false; } else { _dataPath = path; toImport = true; } } if (toSave) { File.WriteAllText(_dataPath, JsonConvert.SerializeObject(_data)); EditorPrefs.SetString(DATA_SAVE_PATH, _dataPath); } if (toImport) { AssetDatabase.ImportAsset(_dataPath.Substring(_dataPath.IndexOf("Assets"))); } } UG.EndVertical(); }
void DoMaterialsGUI() { serializedObject.UpdateIfRequiredOrScript(); EditorGUILayout.PropertyField(m_ImportMaterials, Styles.ImportMaterials); string materialHelp = string.Empty; if (!m_ImportMaterials.hasMultipleDifferentValues) { if (m_ImportMaterials.boolValue) { EditorGUILayout.Popup(m_MaterialLocation, Styles.MaterialLocationOpt, Styles.MaterialLocation); if (!m_MaterialLocation.hasMultipleDifferentValues) { if (m_MaterialLocation.intValue == 0) { // (legacy) we're generating materials in the Materials folder EditorGUILayout.Popup(m_MaterialName, m_ShowAllMaterialNameOptions ? Styles.MaterialNameOptAll : Styles.MaterialNameOptMain, Styles.MaterialName); EditorGUILayout.Popup(m_MaterialSearch, Styles.MaterialSearchOpt, Styles.MaterialSearch); materialHelp = Styles.ExternalMaterialHelpStart.text.Replace("%MAT%", Styles.ExternalMaterialNameHelp[m_MaterialName.intValue].text) + "\n" + Styles.ExternalMaterialSearchHelp[m_MaterialSearch.intValue].text + "\n" + Styles.ExternalMaterialHelpEnd.text; } else if (m_Materials.arraySize > 0 && HasEmbeddedMaterials()) { // we're generating materials inside the prefab materialHelp = Styles.InternalMaterialHelp.text; } } if (targets.Length == 1 && m_Materials.arraySize > 0 && m_MaterialLocation.intValue != 0) { materialHelp += " " + Styles.MaterialAssignmentsHelp.text; } // display the extract buttons if (m_MaterialLocation.intValue != 0 && !m_MaterialLocation.hasMultipleDifferentValues) { ExtractTexturesGUI(); if (ExtractMaterialsGUI()) { return; } } } else { // we're not importing materials materialHelp = Styles.NoMaterialHelp.text; } } if (!string.IsNullOrEmpty(materialHelp)) { EditorGUILayout.HelpBox(materialHelp, MessageType.Info); } if ((targets.Length == 1 || m_SupportsEmbeddedMaterials.hasMultipleDifferentValues == false) && m_SupportsEmbeddedMaterials.boolValue == false && m_MaterialLocation.intValue != 0 && !m_MaterialLocation.hasMultipleDifferentValues) { EditorGUILayout.Space(); EditorGUILayout.HelpBox(Styles.NoMaterialMappingsHelp.text, MessageType.Warning); } // hidden for multi-selection if (m_ImportMaterials.boolValue && targets.Length == 1 && m_Materials.arraySize > 0 && m_MaterialLocation.intValue != 0 && !m_MaterialLocation.hasMultipleDifferentValues) { GUILayout.Label(Styles.ExternalMaterialMappings, EditorStyles.boldLabel); if (MaterialRemapOptons()) { return; } // The list of material names is immutable, whereas the map of external objects can change based on user actions. // For each material name, map the external object associated with it. // The complexity comes from the fact that we may not have an external object in the map, so we can't make a property out of it for (int materialIdx = 0; materialIdx < m_Materials.arraySize; ++materialIdx) { var id = m_Materials.GetArrayElementAtIndex(materialIdx); var name = id.FindPropertyRelative("name").stringValue; var type = id.FindPropertyRelative("type").stringValue; var assembly = id.FindPropertyRelative("assembly").stringValue; SerializedProperty materialProp = null; Material material = null; var propertyIdx = 0; for (int externalObjectIdx = 0, count = m_ExternalObjects.arraySize; externalObjectIdx < count; ++externalObjectIdx) { var pair = m_ExternalObjects.GetArrayElementAtIndex(externalObjectIdx); var externalName = pair.FindPropertyRelative("first.name").stringValue; var externalType = pair.FindPropertyRelative("first.type").stringValue; if (externalName == name && externalType == type) { materialProp = pair.FindPropertyRelative("second"); material = materialProp != null ? materialProp.objectReferenceValue as Material : null; propertyIdx = externalObjectIdx; break; } } GUIContent nameLabel = EditorGUIUtility.TextContent(name); nameLabel.tooltip = name; if (materialProp != null) { EditorGUI.BeginChangeCheck(); EditorGUILayout.ObjectField(materialProp, typeof(Material), nameLabel); if (EditorGUI.EndChangeCheck()) { if (materialProp.objectReferenceValue == null) { m_ExternalObjects.DeleteArrayElementAtIndex(propertyIdx); } } } else { EditorGUI.BeginChangeCheck(); material = EditorGUILayout.ObjectField(nameLabel, material, typeof(Material), false) as Material; if (EditorGUI.EndChangeCheck()) { if (material != null) { var newIndex = m_ExternalObjects.arraySize++; var pair = m_ExternalObjects.GetArrayElementAtIndex(newIndex); pair.FindPropertyRelative("first.name").stringValue = name; pair.FindPropertyRelative("first.type").stringValue = type; pair.FindPropertyRelative("first.assembly").stringValue = assembly; pair.FindPropertyRelative("second").objectReferenceValue = material; } } } } } }
internal void OnGUI() { GUI.Label(new Rect(0, 0, position.width, position.height), GUIContent.none, "grey_border"); GUILayout.Space(3); GUILayout.Label(Styles.header, EditorStyles.boldLabel); GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.nameLabel, GUILayout.Width(90f)); m_Name = EditorGUILayout.TextField(m_Name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.gridLabel, GUILayout.Width(90f)); EditorGUI.BeginChangeCheck(); var newLayout = (Grid.CellLayout)EditorGUILayout.EnumPopup(m_Layout); if (EditorGUI.EndChangeCheck()) { // Set useful user settings for certain layouts switch (newLayout) { case Grid.CellLayout.Rectangle: case Grid.CellLayout.Hexagon: { m_CellSizing = GridPalette.CellSizing.Automatic; m_CellSize = new Vector3(1, 1, 0); break; } case Grid.CellLayout.Isometric: case Grid.CellLayout.IsometricZAsY: { m_CellSizing = GridPalette.CellSizing.Manual; m_CellSize = new Vector3(1, 0.5f, 1); break; } } m_Layout = newLayout; } GUILayout.EndHorizontal(); if (m_Layout == GridLayout.CellLayout.Hexagon) { GUILayout.BeginHorizontal(); float oldLabelWidth = UnityEditor.EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 94; m_HexagonLayout = EditorGUILayout.Popup(Styles.hexagonLabel, m_HexagonLayout, Styles.hexagonSwizzleTypeLabel); EditorGUIUtility.labelWidth = oldLabelWidth; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label(Styles.sizeLabel, GUILayout.Width(90f)); m_CellSizing = (GridPalette.CellSizing)EditorGUILayout.EnumPopup(m_CellSizing); GUILayout.EndHorizontal(); using (new EditorGUI.DisabledScope(m_CellSizing == GridPalette.CellSizing.Automatic)) { GUILayout.BeginHorizontal(); GUILayout.Label(GUIContent.none, GUILayout.Width(90f)); m_CellSize = EditorGUILayout.Vector3Field(GUIContent.none, m_CellSize); GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); // Cancel, Ok GUILayout.BeginHorizontal(); GUILayout.Space(10); if (GUILayout.Button(Styles.cancel)) { Close(); } using (new EditorGUI.DisabledScope(!Utils.Paths.IsValidAssetPath(m_Name))) { if (GUILayout.Button(Styles.ok)) { // case 1077362: Close window to prevent overlap with OS folder window when saving new palette asset Close(); var swizzle = Grid.CellSwizzle.XYZ; if (m_Layout == GridLayout.CellLayout.Hexagon) { swizzle = Styles.hexagonSwizzleTypeValue[m_HexagonLayout]; } GameObject go = GridPaletteUtility.CreateNewPaletteNamed(m_Name, m_Layout, m_CellSizing, m_CellSize, swizzle); if (go != null) { m_Owner.palette = go; m_Owner.Repaint(); } GUIUtility.ExitGUI(); } } GUILayout.Space(10); GUILayout.EndHorizontal(); }
private void DoToolbarGUI() { GameViewSizes.instance.RefreshStandaloneAndRemoteDefaultSizes(); GUILayout.BeginHorizontal(EditorStyles.toolbar); { var types = GetAvailableWindowTypes().OrderBy(type => type.Name).ToList(); if (types.Count > 1) { int viewIndex = EditorGUILayout.Popup(types.IndexOf(typeof(GameView)), types.Select(viewTypes => viewTypes.Name).ToArray(), EditorStyles.toolbarPopup, GUILayout.Width(90)); EditorGUILayout.Space(); if (types[viewIndex].Name != typeof(GameView).Name) { SwapMainWindow(types[viewIndex]); } } if (ModuleManager.ShouldShowMultiDisplayOption()) { int display = EditorGUILayout.Popup(targetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopup, GUILayout.Width(80)); if (display != targetDisplay) { targetDisplay = display; UpdateZoomAreaAndParent(); } } EditorGUILayout.GameViewSizePopup(currentSizeGroupType, selectedSizeIndex, this, EditorStyles.toolbarPopup, GUILayout.Width(160f)); DoZoomSlider(); // If the previous platform and current does not match, update the scale if ((int)currentSizeGroupType != prevSizeGroupType) { UpdateZoomAreaAndParent(); // Update the platform to the recent one prevSizeGroupType = (int)currentSizeGroupType; } if (FrameDebuggerUtility.IsLocalEnabled()) { GUILayout.FlexibleSpace(); Color oldCol = GUI.color; // This has nothing to do with animation recording. Can we replace this color with something else? GUI.color *= AnimationMode.recordedPropertyColor; GUILayout.Label(Styles.frameDebuggerOnContent, EditorStyles.miniLabel); GUI.color = oldCol; // Make frame debugger windows repaint after each time game view repaints. // We want them to always display the latest & greatest game view // rendering state. if (Event.current.type == EventType.Repaint) { FrameDebuggerWindow.RepaintAll(); } } GUILayout.FlexibleSpace(); if (RenderDoc.IsLoaded()) { using (new EditorGUI.DisabledScope(!RenderDoc.IsSupported())) { if (GUILayout.Button(Styles.renderdocContent, EditorStyles.toolbarButton)) { m_Parent.CaptureRenderDocScene(); GUIUtility.ExitGUI(); } } } // Allow the user to select how the XR device will be rendered during "Play In Editor" if (PlayerSettings.virtualRealitySupported) { int selectedRenderMode = EditorGUILayout.Popup(m_XRRenderMode, Styles.xrRenderingModes, EditorStyles.toolbarPopup, GUILayout.Width(80)); SetXRRenderMode(selectedRenderMode); } maximizeOnPlay = GUILayout.Toggle(maximizeOnPlay, Styles.maximizeOnPlayContent, EditorStyles.toolbarButton); EditorUtility.audioMasterMute = GUILayout.Toggle(EditorUtility.audioMasterMute, Styles.muteContent, EditorStyles.toolbarButton); DoVSyncButton(); m_Stats = GUILayout.Toggle(m_Stats, Styles.statsContent, EditorStyles.toolbarButton); if (EditorGUILayout.DropDownToggle(ref m_Gizmos, Styles.gizmosContent, EditorStyles.toolbarDropDownToggleRight)) { Rect rect = GUILayoutUtility.topLevel.GetLast(); if (AnnotationWindow.ShowAtPosition(rect, true)) { GUIUtility.ExitGUI(); } } } GUILayout.EndHorizontal(); }
public override void OnGUI(Rect rect) { if (s_Styles == null) { s_Styles = new Styles(); } GameViewSize other = base.m_Object as GameViewSize; if (other == null) { Debug.LogError("Invalid object"); } else { if (this.m_GameViewSize == null) { this.m_GameViewSize = new GameViewSize(other); } bool flag = (this.m_GameViewSize.width > 0) && (this.m_GameViewSize.height > 0); GUILayout.Space(3f); GUILayout.Label((base.m_MenuType != FlexibleMenuModifyItemUI.MenuType.Add) ? s_Styles.headerEdit : s_Styles.headerAdd, EditorStyles.boldLabel, new GUILayoutOption[0]); FlexibleMenu.DrawRect(GUILayoutUtility.GetRect((float)1f, (float)1f), !EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f)); GUILayout.Space(4f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(90f) }; GUILayout.Label(s_Styles.optionalText, options); GUILayout.Space(10f); this.m_GameViewSize.baseText = EditorGUILayout.TextField(this.m_GameViewSize.baseText, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(90f) }; GUILayout.Label(s_Styles.typeName, optionArray2); GUILayout.Space(10f); this.m_GameViewSize.sizeType = (GameViewSizeType)EditorGUILayout.Popup((int)this.m_GameViewSize.sizeType, s_Styles.typeNames, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(90f) }; GUILayout.Label(s_Styles.widthHeightText, optionArray3); GUILayout.Space(10f); this.m_GameViewSize.width = EditorGUILayout.IntField(this.m_GameViewSize.width, new GUILayoutOption[0]); GUILayout.Space(5f); this.m_GameViewSize.height = EditorGUILayout.IntField(this.m_GameViewSize.height, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.Space(10f); float pixels = 10f; float cropWidth = rect.width - (2f * pixels); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(pixels); GUILayout.FlexibleSpace(); string displayText = this.m_GameViewSize.displayText; using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(displayText))) { if (string.IsNullOrEmpty(displayText)) { displayText = "Result"; } else { displayText = this.GetCroppedText(displayText, cropWidth, EditorStyles.label); } GUILayout.Label(GUIContent.Temp(displayText), EditorStyles.label, new GUILayoutOption[0]); } GUILayout.FlexibleSpace(); GUILayout.Space(pixels); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(10f); if (GUILayout.Button(s_Styles.cancel, new GUILayoutOption[0])) { base.editorWindow.Close(); } using (new EditorGUI.DisabledScope(!flag)) { if (GUILayout.Button(s_Styles.ok, new GUILayoutOption[0])) { other.Set(this.m_GameViewSize); base.Accepted(); base.editorWindow.Close(); } } GUILayout.Space(10f); GUILayout.EndHorizontal(); } }