void OnGUI() { Scroll = EditorGUILayout.BeginScrollView(Scroll); Utility.SetGUIColor(UltiDraw.Black); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Orange); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.LabelField("BVH Importer"); } if (!Importing) { if (Utility.GUIButton("Load Directory", UltiDraw.DarkGrey, UltiDraw.White)) { LoadDirectory(); } if (Utility.GUIButton("Import Motion Data", UltiDraw.DarkGrey, UltiDraw.White)) { this.StartCoroutine(ImportMotionData()); } } else { if (Utility.GUIButton("Stop", UltiDraw.DarkRed, UltiDraw.White)) { this.StopAllCoroutines(); Importing = false; } } using (new EditorGUILayout.VerticalScope("Box")) { EditorGUILayout.LabelField("Source"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("<Path>", GUILayout.Width(50)); Source = EditorGUILayout.TextField(Source); GUI.skin.button.alignment = TextAnchor.MiddleCenter; if (GUILayout.Button("O", GUILayout.Width(20))) { Source = EditorUtility.OpenFolderPanel("BVH Importer", Source == string.Empty ? Application.dataPath : Source, ""); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Destination"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Assets/", GUILayout.Width(50)); Destination = EditorGUILayout.TextField(Destination); EditorGUILayout.EndHorizontal(); string filter = EditorGUILayout.TextField("Filter", Filter); if (Filter != filter) { Filter = filter; ApplyFilter(); } Scale = EditorGUILayout.FloatField("Scale", Scale); EditorGUILayout.BeginHorizontal(); Flip = EditorGUILayout.Toggle("Flip", Flip); Axis = (Axis)EditorGUILayout.EnumPopup(Axis); EditorGUILayout.EndHorizontal(); int start = (Page - 1) * Items; int end = Mathf.Min(start + Items, Instances.Length); int pages = Mathf.CeilToInt(Instances.Length / Items) + 1; Utility.SetGUIColor(UltiDraw.Orange); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("<", UltiDraw.DarkGrey, UltiDraw.White)) { Page = Mathf.Max(Page - 1, 1); } EditorGUILayout.LabelField("Page " + Page + "/" + pages); if (Utility.GUIButton(">", UltiDraw.DarkGrey, UltiDraw.White)) { Page = Mathf.Min(Page + 1, pages); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("Enable All", UltiDraw.DarkGrey, UltiDraw.White)) { for (int i = 0; i < Instances.Length; i++) { Instances[i].Import = true; } } if (Utility.GUIButton("Disable All", UltiDraw.DarkGrey, UltiDraw.White)) { for (int i = 0; i < Instances.Length; i++) { Instances[i].Import = false; } } EditorGUILayout.EndHorizontal(); for (int i = start; i < end; i++) { if (Instances[i].Import) { Utility.SetGUIColor(UltiDraw.DarkGreen); } else { Utility.SetGUIColor(UltiDraw.DarkRed); } using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField((i + 1).ToString(), GUILayout.Width(20f)); Instances[i].Import = EditorGUILayout.Toggle(Instances[i].Import, GUILayout.Width(20f)); EditorGUILayout.LabelField(Instances[i].Object.Name); EditorGUILayout.EndHorizontal(); } } } } } EditorGUILayout.EndScrollView(); }
private void DoPrefabButtons() { if (!m_IsPrefabInstanceAnyRoot || m_IsAsset) { return; } using (new EditorGUI.DisabledScope(m_PlayModeObjects)) { EditorGUILayout.BeginHorizontal(Styles.prefabButtonsHorizontalLayout); // Prefab information PrefabAssetType singlePrefabType = PrefabUtility.GetPrefabAssetType(target); PrefabInstanceStatus singleInstanceStatus = PrefabUtility.GetPrefabInstanceStatus(target); GUIContent prefixLabel; if (targets.Length > 1) { prefixLabel = Styles.goTypeLabelMultiple; } else { prefixLabel = Styles.goTypeLabel[(int)singlePrefabType, (int)singleInstanceStatus]; } if (prefixLabel != null) { EditorGUILayout.BeginHorizontal(GUILayout.Width(kIconSize + Styles.tagFieldWidth)); GUILayout.FlexibleSpace(); if (m_IsDisconnected || m_IsMissing) { GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor; DoPrefixLabel(prefixLabel, EditorStyles.whiteLabel); GUI.contentColor = Color.white; } else { DoPrefixLabel(prefixLabel, EditorStyles.label); } EditorGUILayout.EndHorizontal(); } if (!m_IsMissing) { using (new EditorGUI.DisabledScope(targets.Length > 1)) { if (singlePrefabType == PrefabAssetType.Model) { // Open Model Prefab if (GUILayout.Button(Styles.openModel, EditorStyles.miniButtonLeft)) { GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target); AssetDatabase.OpenAsset(asset); GUIUtility.ExitGUI(); } } else { // Open non-Model Prefab using (new EditorGUI.DisabledScope(m_ImmutableSourceAsset)) { if (GUILayout.Button(m_OpenPrefabContent, EditorStyles.miniButtonLeft)) { GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target); var prefabStageMode = PrefabStageUtility.GetPrefabStageModeFromModifierKeys(); PrefabStageUtility.OpenPrefab(AssetDatabase.GetAssetPath(asset), (GameObject)target, prefabStageMode, StageNavigationManager.Analytics.ChangeType.EnterViaInstanceInspectorOpenButton); GUIUtility.ExitGUI(); } } } } // Select prefab if (GUILayout.Button(Styles.selectString, EditorStyles.miniButtonRight)) { HashSet <GameObject> selectedAssets = new HashSet <GameObject>(); for (int i = 0; i < targets.Length; i++) { GameObject prefabGo = PrefabUtility.GetOriginalSourceOrVariantRoot(targets[i]); // Because of legacy prefab references we have to have this extra step // to make sure we ping the prefab asset correctly. // Reason is that scene files created prior to making prefabs CopyAssets // will reference prefabs as if they are serialized assets. Those references // works fine but we are not able to ping objects loaded directly from the asset // file, so we have to make sure we ping the metadata version of the prefab. var assetPath = AssetDatabase.GetAssetPath(prefabGo); selectedAssets.Add((GameObject)AssetDatabase.LoadMainAssetAtPath(assetPath)); } Selection.objects = selectedAssets.ToArray(); if (Selection.gameObjects.Length == 1) { EditorGUIUtility.PingObject(Selection.activeObject); } } // Should be EditorGUILayout.Space, except it does not have ExpandWidth set to false. // Maybe we can change that? GUILayoutUtility.GetRect(6, 6, GUILayout.ExpandWidth(false)); // Reserve space regardless of whether the button is there or not to avoid jumps in button sizes. Rect rect = GUILayoutUtility.GetRect(Styles.overridesContent, Styles.overridesDropdown); if (m_IsPrefabInstanceOutermostRoot) { if (EditorGUI.DropdownButton(rect, Styles.overridesContent, FocusType.Passive)) { if (targets.Length > 1) { PopupWindow.Show(rect, new PrefabOverridesWindow(targets.Select(e => (GameObject)e).ToArray())); } else { PopupWindow.Show(rect, new PrefabOverridesWindow((GameObject)target)); } GUIUtility.ExitGUI(); } } } EditorGUILayout.EndHorizontal(); } }
private void ItemWasDoubleClicked() { base.Close(); GUIUtility.ExitGUI(); }
private void MaterialListing() { ProceduralMaterial[] sortedMaterials = this.GetSortedMaterials(); ProceduralMaterial[] array = sortedMaterials; for (int i = 0; i < array.Length; i++) { ProceduralMaterial proceduralMaterial = array[i]; if (proceduralMaterial.isProcessing) { base.Repaint(); SceneView.RepaintAll(); GameView.RepaintAll(); break; } } int num = sortedMaterials.Length; float num2 = GUIView.current.position.width - 16f - 18f - 2f; if (num2 * 2f < (float)num * 60f) { num2 -= 16f; } int num3 = Mathf.Max(1, Mathf.FloorToInt(num2 / 60f)); int num4 = Mathf.CeilToInt((float)num / (float)num3); Rect viewRect = new Rect(0f, 0f, (float)num3 * 60f, (float)num4 * 76f); Rect rect = GUILayoutUtility.GetRect(viewRect.width, Mathf.Clamp(viewRect.height, 76f, 152f) + 1f); Rect position = new Rect(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 1f); GUI.Box(rect, GUIContent.none, this.m_SubstanceStyles.gridBackground); GUI.Box(position, GUIContent.none, this.m_SubstanceStyles.background); this.m_ListScroll = GUI.BeginScrollView(position, this.m_ListScroll, viewRect, false, false); if (this.m_EditorCache == null) { this.m_EditorCache = new EditorCache(EditorFeatures.PreviewGUI); } for (int j = 0; j < sortedMaterials.Length; j++) { ProceduralMaterial proceduralMaterial2 = sortedMaterials[j]; if (!(proceduralMaterial2 == null)) { float x = (float)(j % num3) * 60f; float y = (float)(j / num3) * 76f; Rect rect2 = new Rect(x, y, 60f, 76f); bool flag = proceduralMaterial2.name == this.m_SelectedMaterialInstanceName; Event current = Event.current; int controlID = GUIUtility.GetControlID(SubstanceImporterInspector.previewNoDragDropHash, FocusType.Native, rect2); EventType typeForControl = current.GetTypeForControl(controlID); if (typeForControl != EventType.MouseDown) { if (typeForControl == EventType.Repaint) { Rect position2 = rect2; position2.y = rect2.yMax - 16f; position2.height = 16f; this.m_SubstanceStyles.resultsGridLabel.Draw(position2, EditorGUIUtility.TempContent(proceduralMaterial2.name), false, false, flag, flag); } } else if (current.button == 0) { if (rect2.Contains(current.mousePosition)) { if (current.clickCount == 1) { this.m_SelectedMaterialInstanceName = proceduralMaterial2.name; current.Use(); } else if (current.clickCount == 2) { AssetDatabase.OpenAsset(proceduralMaterial2); GUIUtility.ExitGUI(); current.Use(); } } } rect2.height -= 16f; EditorWrapper editorWrapper = this.m_EditorCache[proceduralMaterial2]; editorWrapper.OnPreviewGUI(rect2, this.m_SubstanceStyles.background); } } GUI.EndScrollView(); }
static void OnPostHeaderGUI(Editor editor) { var aaSettings = AddressableAssetSettingsDefaultObject.Settings; if (editor.targets.Length > 0) { foreach (var t in editor.targets) { if (t is AddressableAssetGroup || t is AddressableAssetGroupSchema) { GUILayout.BeginHorizontal(); GUILayout.Label("Profile: " + AddressableAssetSettingsDefaultObject.GetSettings(true).profileSettings. GetProfileName(AddressableAssetSettingsDefaultObject.GetSettings(true).activeProfileId)); GUILayout.FlexibleSpace(); if (GUILayout.Button("System Settings", "MiniButton")) { EditorGUIUtility.PingObject(AddressableAssetSettingsDefaultObject.Settings); Selection.activeObject = AddressableAssetSettingsDefaultObject.Settings; } GUILayout.EndHorizontal(); return; } } List <TargetInfo> targetInfos = GatherTargetInfos(editor.targets, aaSettings); if (targetInfos.Count == 0) { return; } bool targetHasAddressableSubObject = false; int mainAssetsAddressable = 0; int subAssetsAddressable = 0; foreach (TargetInfo info in targetInfos) { if (info.MainAssetEntry == null) { continue; } if (info.MainAssetEntry.IsSubAsset) { subAssetsAddressable++; } else { mainAssetsAddressable++; } if (!info.IsMainAsset) { targetHasAddressableSubObject = true; } } // Overrides a DisabledScope in the EditorElement.cs that disables GUI drawn in the header when the asset cannot be edited. bool prevEnabledState = UnityEngine.GUI.enabled; if (targetHasAddressableSubObject) { UnityEngine.GUI.enabled = false; } else { UnityEngine.GUI.enabled = true; foreach (var info in targetInfos) { if (!info.IsMainAsset) { UnityEngine.GUI.enabled = false; break; } } } int totalAddressableCount = mainAssetsAddressable + subAssetsAddressable; if (totalAddressableCount == 0) // nothing is addressable { if (GUILayout.Toggle(false, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false))) { SetAaEntry(AddressableAssetSettingsDefaultObject.GetSettings(true), targetInfos, true); } } else if (totalAddressableCount == editor.targets.Length) // everything is addressable { var entryInfo = targetInfos[targetInfos.Count - 1]; if (entryInfo == null || entryInfo.MainAssetEntry == null) { throw new NullReferenceException("EntryInfo incorrect for Addressables content."); } GUILayout.BeginHorizontal(); if (mainAssetsAddressable > 0 && subAssetsAddressable > 0) { if (s_ToggleMixed == null) { s_ToggleMixed = new GUIStyle("ToggleMixed"); } if (GUILayout.Toggle(false, s_AddressableAssetToggleText, s_ToggleMixed, GUILayout.ExpandWidth(false))) { SetAaEntry(aaSettings, targetInfos, true); } } else if (mainAssetsAddressable > 0) { if (!GUILayout.Toggle(true, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false))) { SetAaEntry(aaSettings, targetInfos, false); UnityEngine.GUI.enabled = prevEnabledState; GUIUtility.ExitGUI(); } } else if (GUILayout.Toggle(false, s_AddressableAssetToggleText, GUILayout.ExpandWidth(false))) { SetAaEntry(aaSettings, targetInfos, true); } if (editor.targets.Length == 1) { if (!entryInfo.IsMainAsset || entryInfo.MainAssetEntry.IsSubAsset) { bool preAddressPrevEnabledState = UnityEngine.GUI.enabled; UnityEngine.GUI.enabled = false; string address = entryInfo.Address + (entryInfo.IsMainAsset ? "" : $"[{entryInfo.TargetObject.name}]"); EditorGUILayout.DelayedTextField(address, GUILayout.ExpandWidth(true)); UnityEngine.GUI.enabled = preAddressPrevEnabledState; } else { string newAddress = EditorGUILayout.DelayedTextField(entryInfo.Address, GUILayout.ExpandWidth(true)); if (newAddress != entryInfo.Address) { if (newAddress.Contains("[") && newAddress.Contains("]")) { Debug.LogErrorFormat("Rename of address '{0}' cannot contain '[ ]'.", entryInfo.Address); } else { entryInfo.MainAssetEntry.address = newAddress; AddressableAssetUtility.OpenAssetIfUsingVCIntegration(entryInfo.MainAssetEntry.parentGroup, true); } } } } else { FindUniqueAssetGuids(targetInfos, out var uniqueAssetGuids, out var uniqueAddressableAssetGuids); EditorGUILayout.LabelField(uniqueAddressableAssetGuids.Count + " out of " + uniqueAssetGuids.Count + " assets are addressable."); } DrawSelectEntriesButton(targetInfos); GUILayout.EndHorizontal(); } else // mixed addressable selected { GUILayout.BeginHorizontal(); if (s_ToggleMixed == null) { s_ToggleMixed = new GUIStyle("ToggleMixed"); } if (GUILayout.Toggle(false, s_AddressableAssetToggleText, s_ToggleMixed, GUILayout.ExpandWidth(false))) { SetAaEntry(AddressableAssetSettingsDefaultObject.GetSettings(true), targetInfos, true); } FindUniqueAssetGuids(targetInfos, out var uniqueAssetGuids, out var uniqueAddressableAssetGuids); EditorGUILayout.LabelField(uniqueAddressableAssetGuids.Count + " out of " + uniqueAssetGuids.Count + " assets are addressable."); DrawSelectEntriesButton(targetInfos); GUILayout.EndHorizontal(); } UnityEngine.GUI.enabled = prevEnabledState; } }
void DrawListElement(Rect rect, bool even, AInfo ainfo) { if (ainfo == null) { Debug.LogError("DrawListElement: AInfo not valid!"); return; } string tooltip; float togglerSize = 17; float disabledAlpha = 0.3f; // We maintain our own gui.changed bool orgGUIChanged = GUI.changed; bool orgGUIEnabled = GUI.enabled; Color orgColor = GUI.color; GUI.changed = false; GUI.enabled = true; // Bg GUIStyle backgroundStyle = even ? m_Styles.listEvenBg : m_Styles.listOddBg; GUI.Label(rect, GUIContent.Temp(""), backgroundStyle); // Text Rect textRect = rect; //textRect.x += 22; textRect.width = rect.width - iconRightAlign - 22; // ensure text doesnt flow behind toggles GUI.Label(textRect, ainfo.m_DisplayText, m_Styles.listTextStyle); // Icon toggle float iconSize = 16; Rect iconRect = new Rect(rect.width - iconRightAlign, rect.y + (rect.height - iconSize) * 0.5f, iconSize, iconSize); Texture thumb = null; if (ainfo.m_ScriptClass != "") { // Icon for scripts thumb = EditorGUIUtility.GetIconForObject(EditorGUIUtility.GetScript(ainfo.m_ScriptClass)); Rect div = iconRect; div.x += 18; div.y += 1; div.width = 1; div.height = 12; if (!EditorGUIUtility.isProSkin) { GUI.color = new Color(0, 0, 0, 0.33f); } else { GUI.color = new Color(1, 1, 1, 0.13f); } GUI.DrawTexture(div, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill); GUI.color = Color.white; Rect arrowRect = iconRect; arrowRect.x += 18; arrowRect.y += 0; arrowRect.width = 9; if (GUI.Button(arrowRect, iconSelectContent, m_Styles.iconDropDown)) { Object script = EditorGUIUtility.GetScript(ainfo.m_ScriptClass); if (script != null) { m_LastScriptThatHasShownTheIconSelector = ainfo.m_ScriptClass; if (IconSelector.ShowAtPosition(script, arrowRect, true)) { IconSelector.SetMonoScriptIconChangedCallback(MonoScriptIconChanged); GUIUtility.ExitGUI(); } } } } else { // Icon for builtin components if (ainfo.HasIcon()) { thumb = AssetPreview.GetMiniTypeThumbnailFromClassID(ainfo.m_ClassID); } } if (thumb != null) { if (!ainfo.m_IconEnabled) { GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, disabledAlpha); tooltip = ""; } iconToggleContent.image = thumb; if (GUI.Button(iconRect, iconToggleContent, GUIStyle.none)) { ainfo.m_IconEnabled = !ainfo.m_IconEnabled; SetIconState(ainfo); } GUI.color = orgColor; } if (GUI.changed) { SetIconState(ainfo); GUI.changed = false; } GUI.enabled = true; GUI.color = orgColor; // Gizmo toggle if (ainfo.HasGizmo()) { tooltip = textGizmoVisible; Rect togglerRect = new Rect(rect.width - gizmoRightAlign, rect.y + (rect.height - togglerSize) * 0.5f, togglerSize, togglerSize); ainfo.m_GizmoEnabled = GUI.Toggle(togglerRect, ainfo.m_GizmoEnabled, new GUIContent("", tooltip), m_Styles.toggle); if (GUI.changed) { SetGizmoState(ainfo); } } GUI.enabled = orgGUIEnabled; GUI.changed = orgGUIChanged; GUI.color = orgColor; }
public override void DoGUI() { fsmEditor.OnGUI(); /* Debug Repaint events * if (Event.current.type == EventType.repaint) * { * Debug.Log("Repaint"); * }*/ if (Event.current.type == EventType.ValidateCommand) { switch (Event.current.commandName) { case "UndoRedoPerformed": case "Cut": case "Copy": case "Paste": case "SelectAll": Event.current.Use(); break; } } if (Event.current.type == EventType.ExecuteCommand) { switch (Event.current.commandName) { /* replaced with Undo.undoRedoPerformed callback added in Unity 4.3 * case "UndoRedoPerformed": * FsmEditor.UndoRedoPerformed(); * break; */ case "Cut": FsmEditor.Cut(); break; case "Copy": FsmEditor.Copy(); break; case "Paste": FsmEditor.Paste(); break; case "SelectAll": FsmEditor.SelectAll(); break; case "OpenWelcomeWindow": GetWindow <PlayMakerWelcomeWindow>(); break; case "OpenToolWindow": toolWindow = GetWindow <ContextToolWindow>(); break; case "OpenFsmSelectorWindow": fsmSelectorWindow = GetWindow <FsmSelectorWindow>(); fsmSelectorWindow.ShowUtility(); break; case "OpenFsmTemplateWindow": fsmTemplateWindow = GetWindow <FsmTemplateWindow>(); break; case "OpenStateSelectorWindow": stateSelectorWindow = GetWindow <FsmStateWindow>(); break; case "OpenActionWindow": actionWindow = GetWindow <FsmActionWindow>(); break; case "OpenGlobalEventsWindow": globalEventsWindow = GetWindow <FsmEventsWindow>(); break; case "OpenGlobalVariablesWindow": globalVariablesWindow = GetWindow <FsmGlobalsWindow>(); break; case "OpenErrorWindow": errorWindow = GetWindow <FsmErrorWindow>(); break; case "OpenTimelineWindow": timelineWindow = GetWindow <FsmTimelineWindow>(); break; case "OpenFsmLogWindow": logWindow = GetWindow <FsmLogWindow>(); break; case "OpenAboutWindow": aboutWindow = GetWindow <AboutWindow>(); break; case "OpenReportWindow": reportWindow = GetWindow <ReportWindow>(); break; case "AddFsmComponent": PlayMakerMainMenu.AddFsmToSelected(); break; case "RepaintAll": RepaintAllWindows(); break; case "ChangeLanguage": ResetWindowTitles(); break; } GUIUtility.ExitGUI(); } }
private void DoPopupMenu(EditorWindow console) { var listView = consoleListViewField.GetValue(console); int listViewRow = listView != null ? (int)listViewStateRowField.GetValue(listView) : -1; if (listViewRow < 0) { return; } string text = (string)consoleActiveTextField.GetValue(console); if (string.IsNullOrEmpty(text)) { return; } GenericMenu codeViewPopupMenu = new GenericMenu(); string[] lines = text.Split('\n'); foreach (string line in lines) { int atAssetsIndex = line.IndexOf("(at Assets/"); if (atAssetsIndex < 0) { continue; } int functionNameEnd = line.IndexOf('('); if (functionNameEnd < 0) { continue; } string functionName = line.Substring(0, functionNameEnd).TrimEnd(' '); int lineIndex = line.LastIndexOf(':'); if (lineIndex <= atAssetsIndex) { continue; } int atLine = 0; for (int i = lineIndex + 1; i < line.Length; ++i) { char c = line[i]; if (c < '0' || c > '9') { break; } atLine = atLine * 10 + (c - '0'); } atAssetsIndex += "(at ".Length; string assetPath = line.Substring(atAssetsIndex, lineIndex - atAssetsIndex); string scriptName = assetPath.Substring(assetPath.LastIndexOf('/') + 1); string guid = AssetDatabase.AssetPathToGUID(assetPath); if (!string.IsNullOrEmpty(guid)) { codeViewPopupMenu.AddItem( new GUIContent(scriptName + " - " + functionName.Replace(':', '.') + ", line " + atLine), false, () => { bool openInSI = (openLogEntriesInSi2 || SISettings.handleOpenAssets) && !SISettings.dontOpenAssets; if (EditorGUI.actionKey) { openInSI = !openInSI; } if (openInSI) { FGCodeWindow.addRecentLocationForNextAsset = true; FGCodeWindow.OpenAssetInTab(guid, atLine); } else { FGCodeWindow.openInExternalIDE = true; AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath(assetPath), atLine); } }); } } if (codeViewPopupMenu.GetItemCount() > 0) { codeViewPopupMenu.AddSeparator(string.Empty); if (SISettings.handleOpenAssets || SISettings.dontOpenAssets) { codeViewPopupMenu.AddDisabledItem( new GUIContent("Open Call-Stack Entries in Script Inspector") ); } else { codeViewPopupMenu.AddItem( new GUIContent("Open Call-Stack Entries in Script Inspector"), openLogEntriesInSi2, () => { openLogEntriesInSi2 = !openLogEntriesInSi2; } ); } GUIUtility.hotControl = 0; codeViewPopupMenu.ShowAsContext(); GUIUtility.ExitGUI(); } }
/// <summary> /// Do the GUI /// </summary> void OnGUI() { fsmEditor.OnGUI(); /* BeginWindows(); * * fsmEditor.DoPopupWindows(); * * EndWindows();*/ if (Event.current.type == EventType.ValidateCommand) { //Debug.Log(Event.current.commandName); switch (Event.current.commandName) { case "UndoRedoPerformed": Event.current.Use(); break; case "Copy": Event.current.Use(); break; case "Paste": Event.current.Use(); break; case "SelectAll": Event.current.Use(); break; } } if (Event.current.type == EventType.ExecuteCommand) { //Debug.Log(Event.current.commandName); switch (Event.current.commandName) { case "UndoRedoPerformed": FsmEditor.UndoRedoPerformed(); break; case "Copy": FsmEditor.Copy(); break; case "Paste": FsmEditor.Paste(); break; case "SelectAll": FsmEditor.SelectAll(); break; case "OpenWelcomeWindow": GetWindow <PlayMakerWelcomeWindow>(); break; case "OpenToolWindow": toolWindow = GetWindow <ContextToolWindow>(); break; case "OpenFsmSelectorWindow": fsmSelectorWindow = GetWindow <FsmSelectorWindow>(); fsmSelectorWindow.ShowUtility(); break; case "OpenFsmTemplateWindow": fsmTemplateWindow = GetWindow <FsmTemplateWindow>(); break; case "OpenStateSelectorWindow": stateSelectorWindow = GetWindow <FsmStateWindow>(); break; case "OpenActionWindow": actionWindow = GetWindow <FsmActionWindow>(); break; case "OpenGlobalEventsWindow": globalEventsWindow = GetWindow <FsmEventsWindow>(); break; case "OpenGlobalVariablesWindow": globalVariablesWindow = GetWindow <FsmGlobalsWindow>(); break; case "OpenErrorWindow": errorWindow = GetWindow <FsmErrorWindow>(); break; case "OpenFsmLogWindow": logWindow = GetWindow <FsmLogWindow>(); break; case "OpenAboutWindow": aboutWindow = GetWindow <AboutWindow>(); break; case "OpenReportWindow": reportWindow = GetWindow <ReportWindow>(); break; case "AddFsmComponent": PlayMakerMainMenu.AddFsmToSelected(); break; case "RepaintAll": RepaintAllWindows(); break; } GUIUtility.ExitGUI(); } }
private void OnGUI() { EditorGUIUtility.labelWidth = 150f; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.ExpandHeight(true) }; GUILayout.Label(this.m_HelpString, EditorStyles.wordWrappedLabel, options); this.m_ScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.m_ScrollPosition, false, GUI.skin.verticalScrollbar, "OL Box", new GUILayoutOption[0]); GUIUtility.GetControlID(0x9da9d, FocusType.Passive); bool flag = this.DrawWizardGUI(); EditorGUILayout.EndScrollView(); GUILayout.BeginVertical(new GUILayoutOption[0]); if (this.m_ErrorString != string.Empty) { GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.MinHeight(32f) }; GUILayout.Label(this.m_ErrorString, Styles.errorText, optionArray2); } else { GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.MinHeight(32f) }; GUILayout.Label(string.Empty, optionArray3); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUI.enabled = this.m_IsValid; if (this.m_OtherButton != string.Empty) { GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.MinWidth(100f) }; if (GUILayout.Button(this.m_OtherButton, optionArray4)) { MethodInfo method = base.GetType().GetMethod("OnWizardOtherButton", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (method != null) { method.Invoke(this, null); GUIUtility.ExitGUI(); } else { Debug.LogError("OnWizardOtherButton has not been implemented in script"); } } } if (this.m_CreateButton != string.Empty) { GUILayoutOption[] optionArray5 = new GUILayoutOption[] { GUILayout.MinWidth(100f) }; if (GUILayout.Button(this.m_CreateButton, optionArray5)) { MethodInfo info2 = base.GetType().GetMethod("OnWizardCreate", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (info2 != null) { info2.Invoke(this, null); } else { Debug.LogError("OnWizardCreate has not been implemented in script"); } base.Close(); GUIUtility.ExitGUI(); } } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (flag) { this.InvokeWizardUpdate(); } }
protected void OnGUI() { if (Event.current.isKey && TabSwitcher.OnGUIGlobal()) { return; } EditorWindow console = consoleWindowField.GetValue(null) as EditorWindow; if (console == null) { EditorGUILayout.HelpBox(@"Script Inspector Console can only work when the Console tab is also open. Click the button below to open the Console window...", MessageType.Info); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Open Console Widnow")) { GetWindow(consoleWindowType); Focus(); Repaint(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); return; } Rect oldPosition = console.position; editorWindowPosField.SetValue(console, position); try { bool contextClick = Event.current.type == EventType.ContextClick || Event.current.type == EventType.MouseUp && Event.current.button == 1 && Application.platform == RuntimePlatform.OSXEditor; if (contextClick && GUIUtility.hotControl == 0 && Event.current.mousePosition.y > EditorStyles.toolbar.fixedHeight) { int lvHeight = (int)consoleLVHeightField.GetValue(console); if (lvHeight > Event.current.mousePosition.y - EditorStyles.toolbar.fixedHeight) { Event.current.type = EventType.MouseDown; Event.current.button = 0; Event.current.clickCount = 1; try { consoleOnGUIMethod.Invoke(console, null); } catch { } GUIUtility.hotControl = 0; DoPopupMenu(console); } } else if (Event.current.type == EventType.MouseDown && Event.current.clickCount == 2 && Event.current.mousePosition.y > EditorStyles.toolbar.fixedHeight || Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { OpenLogEntry(console); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); } try { consoleOnGUIMethod.Invoke(console, null); } catch { } var rc = new Rect(254f, -1f, 144f, 18f); var autoFocusText = SISettings.autoFocusConsole == 0 ? "Auto-Focus: Never" : SISettings.autoFocusConsole == 1 ? "Auto-Focus: On Error" : "Auto-Focus: On Compile"; if (GUI.Button(rc, autoFocusText, EditorStyles.toolbarDropDown)) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Never"), SISettings.autoFocusConsole == 0, () => { SISettings.autoFocusConsole.Value = 0; }); menu.AddItem(new GUIContent("On Compile Error"), SISettings.autoFocusConsole == 1, () => { SISettings.autoFocusConsole.Value = 1; }); menu.AddItem(new GUIContent("On Compile"), SISettings.autoFocusConsole == 2, () => { SISettings.autoFocusConsole.Value = 2; }); menu.DropDown(rc); } } finally { editorWindowPosField.SetValue(console, oldPosition); } }
void OnGUI() { TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position); GUIStyle padding = new GUIStyle(); padding.padding = new RectOffset(3, 3, 3, 3); GUILayout.BeginVertical(padding); // show list of items showItems(); GUILayout.Space(3f); GUILayout.BeginHorizontal(); if (GUILayout.Button("All", GUILayout.Width(50f))) { for (int i = 0; i < gameObjsSelected.Count; i++) { if (gameObjsSelected[i] == false) { gameObjsSelected[i] = true; } } } if (GUILayout.Button("None", GUILayout.Width(50f))) { for (int i = 0; i < gameObjsSelected.Count; i++) { if (gameObjsSelected[i] == true) { gameObjsSelected[i] = false; } } } GUILayout.FlexibleSpace(); if (GUILayout.Button("Export...", GUILayout.Width(80f))) { bool shouldExit = false; bool performExport = true; if (string.IsNullOrEmpty(EditorSceneManager.GetActiveScene().name)) { if (UnityEditor.EditorUtility.DisplayDialog("Save Current Scene", "The current scene must be saved before an export is performed.", "Save Current Scene", "Cancel")) { EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene()); UnityEditor.EditorUtility.DisplayDialog("Performing Export...", "The current scene has been saved. Now performing export.", "Continue"); } else { performExport = false; } } if (performExport) { if (saveSelectedItemsToScene()) { shouldExit = true; } } if (shouldExit) { this.Close(); GUIUtility.ExitGUI(); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
public override void OnInspectorGUI() { LinkerData _target = target as LinkerData; FsmEditorStyles.Init(); //GUILayout.Box("Hello",FsmEditorStyles.LargeTitleWithLogo,GUILayout.Height(42f)); GUI.Box(new Rect(0f, 0f, Screen.width, 42f), "Linker Wizard", FsmEditorStyles.LargeTitleWithLogo); GUILayout.Label("1: Make sure you installed them actions"); if (GUILayout.Button("Install Actions")) { Debug.Log("importing package " + Application.dataPath + "/" + ActionsPackagePath); AssetDatabase.ImportPackage(Application.dataPath + "/" + ActionsPackagePath, true); } GUILayout.Label("2: Check 'debug' for tracking all reflections"); EditorGUI.indentLevel++; bool _debug = EditorGUILayout.Toggle("Debug", _target.debug); EditorGUI.indentLevel--; if (_debug != _target.debug) { _target.debug = _debug; EditorUtility.SetDirty(_target); } GUILayout.Label("3: Run your scenes from start to finish"); GUILayout.Label(" Check the Unity Console for usages "); GUILayout.Label("4: Update Linker xml file"); if (GUILayout.Button("Update Linker content")) { UpdateLinkerContent(_target); GUIUtility.ExitGUI(); } if (_target.LinkContentUpdateDone) { GUILayout.Label("5: You can now publish and test on device"); if (GUILayout.Button("Ping Link.xml in Project")) { AssetDatabase.Refresh(); EditorGUIUtility.PingObject(_target.Asset); } } GUILayout.BeginHorizontal(GUILayout.Height(25)); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); FsmEditorGUILayout.Divider(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.Label("preview", GUILayout.ExpandWidth(false)); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); FsmEditorGUILayout.Divider(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); foreach (KeyValuePair <string, List <string> > entry in _target.linkerEntries) { GUILayout.Label(entry.Key); foreach (string _item in entry.Value) { GUILayout.Label(" " + _item); } } }
private void DragTab(Rect pos, GUIStyle tabStyle) { int controlID = GUIUtility.GetControlID(FocusType.Passive); float tabWidth = this.GetTabWidth(pos.width); Event current = Event.current; if ((s_DragMode != 0) && (GUIUtility.hotControl == 0)) { PaneDragTab.get.Close(); ResetDragVars(); } EventType typeForControl = current.GetTypeForControl(controlID); switch (typeForControl) { case EventType.MouseDown: if (pos.Contains(current.mousePosition) && (GUIUtility.hotControl == 0)) { int tabAtMousePos = this.GetTabAtMousePos(current.mousePosition, pos); if (tabAtMousePos < this.m_Panes.Count) { switch (current.button) { case 0: if (tabAtMousePos != this.selected) { this.selected = tabAtMousePos; } GUIUtility.hotControl = controlID; s_StartDragPosition = current.mousePosition; s_DragMode = 0; current.Use(); break; case 2: this.m_Panes[tabAtMousePos].Close(); current.Use(); break; } } } goto Label_06B9; case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { Vector2 vector3 = GUIUtility.GUIToScreenPoint(current.mousePosition); if (s_DragMode != 0) { s_DragMode = 0; PaneDragTab.get.Close(); EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists)); if ((s_DropInfo == null) || (s_DropInfo.dropArea == null)) { EditorWindow pane = s_DragPane; ResetDragVars(); this.RemoveTab(pane); Rect position = pane.position; position.x = vector3.x - (position.width * 0.5f); position.y = vector3.y - (position.height * 0.5f); if (Application.platform == RuntimePlatform.WindowsEditor) { position.y = Mathf.Max(InternalEditorUtility.GetBoundsOfDesktopAtPoint(vector3).y, position.y); } EditorWindow.CreateNewWindowForEditorWindow(pane, false, false); pane.position = pane.m_Parent.window.FitWindowRectToScreen(position, true, true); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); } else { s_DropInfo.dropArea.PerformDrop(s_DragPane, s_DropInfo, vector3); } ResetDragVars(); } GUIUtility.hotControl = 0; current.Use(); } goto Label_06B9; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { Vector2 vector = current.mousePosition - s_StartDragPosition; current.Use(); Rect screenPosition = base.screenPosition; if ((s_DragMode == 0) && (vector.sqrMagnitude > 99f)) { s_DragMode = 1; s_PlaceholderPos = this.selected; s_DragPane = this.m_Panes[this.selected]; if (this.m_Panes.Count != 1) { s_IgnoreDockingForView = null; } else { s_IgnoreDockingForView = this; } s_OriginalDragSource = this; PaneDragTab.get.content = s_DragPane.titleContent; base.Internal_SetAsActiveWindow(); PaneDragTab.get.GrabThumbnail(); PaneDragTab.get.Show(new Rect((pos.x + screenPosition.x) + (tabWidth * this.selected), pos.y + screenPosition.y, tabWidth, pos.height), GUIUtility.GUIToScreenPoint(current.mousePosition)); EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(DockArea.CheckDragWindowExists)); GUIUtility.ExitGUI(); } if (s_DragMode == 1) { DropInfo di = null; ContainerWindow[] windows = ContainerWindow.windows; Vector2 screenPos = GUIUtility.GUIToScreenPoint(current.mousePosition); ContainerWindow inFrontOf = null; foreach (ContainerWindow window2 in windows) { foreach (View view in window2.mainView.allChildren) { IDropArea area = view as IDropArea; if (area != null) { di = area.DragOver(s_DragPane, screenPos); } if (di != null) { break; } } if (di != null) { inFrontOf = window2; break; } } if (di == null) { di = new DropInfo(null); } if (di.type != DropInfo.Type.Tab) { s_PlaceholderPos = -1; } s_DropInfo = di; if (PaneDragTab.get.m_Window != null) { PaneDragTab.get.SetDropInfo(di, screenPos, inFrontOf); } } } goto Label_06B9; case EventType.Repaint: { float xMin = pos.xMin; int num8 = 0; if (base.actualView == null) { Rect rect5 = new Rect(xMin, pos.yMin, tabWidth, pos.height); float x = Mathf.Round(rect5.x); Rect rect6 = new Rect(x, rect5.y, Mathf.Round(rect5.x + rect5.width) - x, rect5.height); tabStyle.Draw(rect6, "Failed to load", false, false, true, false); } else { for (int i = 0; i < this.m_Panes.Count; i++) { if (s_DragPane != this.m_Panes[i]) { if (((s_DropInfo != null) && object.ReferenceEquals(s_DropInfo.dropArea, this)) && (s_PlaceholderPos == num8)) { xMin += tabWidth; } Rect rect3 = new Rect(xMin, pos.yMin, tabWidth, pos.height); float num10 = Mathf.Round(rect3.x); Rect rect4 = new Rect(num10, rect3.y, Mathf.Round(rect3.x + rect3.width) - num10, rect3.height); tabStyle.Draw(rect4, this.m_Panes[i].titleContent, false, false, i == this.selected, base.hasFocus); xMin += tabWidth; num8++; } } } goto Label_06B9; } } if ((typeForControl == EventType.ContextClick) && (pos.Contains(current.mousePosition) && (GUIUtility.hotControl == 0))) { int num4 = this.GetTabAtMousePos(current.mousePosition, pos); if (num4 < this.m_Panes.Count) { base.PopupGenericMenu(this.m_Panes[num4], new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f)); } } Label_06B9: this.selected = Mathf.Clamp(this.selected, 0, this.m_Panes.Count - 1); }
private void DoToolbarGUI() { GameViewSizes.instance.RefreshStandaloneAndRemoteDefaultSizes(); GUILayout.BeginHorizontal(EditorStyles.toolbar); { var availableTypes = GetAvailableWindowTypes(); if (availableTypes.Count > 1) { var typeNames = availableTypes.Values.ToList(); var types = availableTypes.Keys.ToList(); int viewIndex = EditorGUILayout.Popup(typeNames.IndexOf(titleContent.text), typeNames.ToArray(), EditorStyles.toolbarPopup, GUILayout.Width(90)); EditorGUILayout.Space(); if (types[viewIndex] != typeof(GameView)) { SwapMainWindow(types[viewIndex]); } } if (ModuleManager.ShouldShowMultiDisplayOption()) { int display = EditorGUILayout.Popup(targetDisplay, DisplayUtility.GetDisplayNames(), EditorStyles.toolbarPopupLeft, 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.toolbarLabel); 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); 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 void Ui(BGTableView ui) { var cursor = 0; // ========================== First row //number ui.NextColumn("" + index, "Field's index", GetWidth(ui, ref cursor)); //name ui.NextColumn(rect => { BGEditorUtility.TextField(rect, field.FieldName, s => { if (NameHasError(field.Curve, s)) { return; } Change(() => field.FieldName = s); }, true); }, GetWidth(ui, ref cursor)); //type ui.NextColumn(field.Type.ToString(), "Field's Type", GetWidth(ui, ref cursor)); //show in Points menu ui.NextColumn(rect => BGEditorUtility.BoolField(rect, BGPrivateField.GetShowInPointsMenu(field), b => Change(() => BGPrivateField.SetShowInPointsMenu(field, b))), GetWidth(ui, ref cursor)); //delete icon ui.NextColumn(rect => { if (!GUI.Button(rect, deleteIcon) || !BGEditorUtility.Confirm("Delete", "Are you sure you want to delete '" + field.FieldName + "' field?", "Delete")) { return; } BGPrivateField.Invoke(field.Curve, BGCurve.MethodDeleteField, field, (Action <BGCurvePointField>)Undo.DestroyObjectImmediate); GUIUtility.ExitGUI(); }, GetWidth(ui, ref cursor)); //\r\n ui.NextRow(); // ========================== Second row //does not support if (!SupportHandles(field.Type)) { return; } ui.NextColumn(" Handles", "Field's index", 25); //handles type ui.NextColumn( rect => BGEditorUtility.PopupField(rect, (HandlesType)BGPrivateField.GetHandlesType(field), Type2Handles[field.Type], b => Change(() => BGPrivateField.SetHandlesType(field, (int)((HandlesType)b)))), 30); //Handles color ui.NextColumn(rect => BGEditorUtility.ColorField(rect, BGPrivateField.GetHandlesColor(field), b => Change(() => BGPrivateField.SetHandlesColor(field, b))), 30); //show handles in Scene View ui.NextColumn(rect => BGEditorUtility.BoolField(rect, BGPrivateField.GetShowHandles(field), b => Change(() => BGPrivateField.SetShowHandles(field, b))), 5); //empty column under delete button ui.NextColumn(rect => EditorGUI.LabelField(rect, ""), 10); //\r\n ui.NextRow(); }
public override void OnInspectorGUI() { serializedObject.Update(); if (m_Collection.SharedData == null) { EditorGUILayout.HelpBox(Styles.missingSharedTableData, MessageType.Error); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_SharedTableData); if (EditorGUI.EndChangeCheck()) { RefreshTables(); } return; } if (EditorGUILayout.PropertyField(m_Tables, false)) { EditorGUI.indentLevel++; var tables = m_Collection.Tables; for (int i = 0; i < tables.Count; ++i) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(tables[i].asset?.name, EditorStyles.label)) { EditorGUIUtility.PingObject(tables[i].asset); } if (GUILayout.Button(Styles.removeTable, GUILayout.Width(60))) { m_Collection.RemoveTable(tables[i].asset, createUndo: true); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } // Loose tables if (m_LooseTables.Count > 0) { m_ShowLooseTables = EditorGUILayout.Foldout(m_ShowLooseTables, Styles.looseTables); if (m_ShowLooseTables) { EditorGUILayout.HelpBox(Styles.looseTablesInfo); EditorGUI.indentLevel++; for (int i = 0; i < m_LooseTables.Count; ++i) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(m_LooseTables[i].name, EditorStyles.label)) { EditorGUIUtility.PingObject(m_LooseTables[i]); } if (GUILayout.Button(Styles.addTable, GUILayout.Width(50))) { m_Collection.AddTable(m_LooseTables[i], createUndo: true); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } } // Missing tables if (m_MissingTables.Count > 0) { m_ShowMissingTables = EditorGUILayout.Foldout(m_ShowMissingTables, Styles.missingTables); if (m_ShowMissingTables) { EditorGUILayout.HelpBox(Styles.missingTablesInfo); EditorGUI.indentLevel++; for (int i = 0; i < m_MissingTables.Count; ++i) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(m_MissingTables[i].name, EditorStyles.label)) { EditorGUIUtility.PingObject(m_MissingTables[i]); } if (GUILayout.Button(Styles.createTable, GUILayout.Width(60))) { m_Collection.AddNewTable(m_MissingTables[i].Identifier); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } } if (GUILayout.Button(Styles.editCollection)) { LocalizationTablesWindow.ShowWindow(target as LocalizationTableCollection); } EditorGUILayout.PropertyField(m_Group, Styles.group); m_ExtensionsList.DoLayoutList(); serializedObject.ApplyModifiedProperties(); }
// ================================================================================ Inspector public override void OnInspectorGui() { var settings = BGPrivateField.GetSettings(Curve); BGEditorUtility.HelpBox("Curve UI is disabled in settings. All handles are disabled too.", MessageType.Warning, !settings.ShowCurve); // Custom fields var warning = ""; BGEditorUtility.Assign(ref customUi, () => new BGTableView("Custom fields", new[] { "#", "Name", "Type", "?", "Delete" }, new[] { 5, 40, 40, 5, 10 }, () => { //add row customUi.NextColumn(rect => EditorGUI.LabelField(rect, "Name"), 12); customUi.NextColumn(rect => newFieldName = EditorGUI.TextField(rect, newFieldName), 28); customUi.NextColumn(rect => BGEditorUtility.PopupField(rect, newFieldType, @enum => newFieldType = (BGCurvePointField.TypeEnum)@enum), 50); customUi.NextColumn(rect => { if (!GUI.Button(rect, BGBinaryResources.BGAdd123)) { return; } if (NameHasError(Curve, newFieldName)) { return; } BGPrivateField.Invoke(Curve, BGCurve.MethodAddField, newFieldName, newFieldType, (Func <BGCurvePointField>)(() => Undo.AddComponent <BGCurvePointField>(Curve.gameObject))); GUIUtility.hotControl = 0; GUIUtility.ExitGUI(); }, 10); customUi.NextRow(); if (customFields == null || customFields.Length == 0) { customUi.NextRow("Name should be 16 chars max, starts with a letter and contain English chars and numbers only."); } else { //header customUi.DrawHeaders(); //fields var quaternionWithHandlesCount = 0; BGEditorUtility.ChangeCheck(() => { foreach (var customField in customFields) { if (customField.Field.Type == BGCurvePointField.TypeEnum.Quaternion && BGPrivateField.GetHandlesType(customField.Field) != 0) { quaternionWithHandlesCount++; } customField.Ui(customUi); } }, SceneView.RepaintAll); if (quaternionWithHandlesCount > 1) { warning = "You have more than one Quaternion field with Handles enabled. Only first field will be shown in Scene View"; } //footer customUi.NextRow("?- Show in Points Menu/Scene View"); } })); // System fields BGEditorUtility.Assign(ref systemUi, () => new BGTableView("System fields", new[] { "Name", "Value" }, new[] { LabelWidth, 100 - LabelWidth }, () => { BGEditorUtility.ChangeCheck(() => { foreach (var field in systemFields) { field.Ui(systemUi); } }, SceneView.RepaintAll); })); BGEditorUtility.Assign(ref systemFields, () => new[] { (SystemField) new SystemFieldPosition(settings), new SystemFieldControls(settings), new SystemFieldControlsType(settings), new SystemFieldTransform(settings), }); var fields = Curve.Fields; var hasFields = fields != null && fields.Length > 0; if (hasFields && (customFields == null || customFields.Length != fields.Length) || !hasFields && customFields != null && customFields.Length != fields.Length) { customFields = new PointField[fields.Length]; for (var i = 0; i < fields.Length; i++) { customFields[i] = new PointField(fields[i], i, BGBinaryResources.BGDelete123); } } //warnings BGEditorUtility.HelpBox("All handles for positions are disabled.", MessageType.Warning, settings.HandlesSettings.Disabled); BGEditorUtility.HelpBox("All handles for controls are disabled.", MessageType.Warning, settings.ControlHandlesSettings.Disabled); //====================== Custom fields customUi.OnGui(); //warnings BGEditorUtility.HelpBox(warning, MessageType.Warning, warning.Length > 0); //====================== System fields systemUi.OnGui(); GUILayout.Space(4); }
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) { Rect tempRect = rect; tempRect.height = EditorGUIUtility.singleLineHeight; float startX = tempRect.x; float startWidth = tempRect.width; SerializedProperty typeProp = prop.FindPropertyRelative("m_Type"); GUIContent typeLabel = new GUIContent(prop.displayName); Vector2 typeSize = EditorStyles.label.CalcSize(typeLabel); tempRect.width = typeSize.x + 20f; EditorGUI.LabelField(tempRect, typeLabel); tempRect.x += tempRect.width; tempRect.width = 60; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(tempRect, typeProp, GUIContent.none); Sprite.Type spriteType = (Sprite.Type)typeProp.enumValueIndex; if (EditorGUI.EndChangeCheck()) { if (spriteType == Sprite.Type.Atlas) { prop.FindPropertyRelative("m_Sprite").objectReferenceValue = null; } else { prop.FindPropertyRelative("m_AtlasRaw").objectReferenceValue = null; prop.FindPropertyRelative("m_SpriteName").stringValue = null; } } tempRect.x += tempRect.width; if (spriteType == Sprite.Type.Atlas) { SerializedProperty atlasRawProp = prop.FindPropertyRelative("m_AtlasRaw"); SerializedProperty spriteNameProp = prop.FindPropertyRelative("m_SpriteName"); tempRect.width = startWidth - (tempRect.x - startX); var controlId = GUIUtility.GetControlID(FocusType.Passive); var eventType = Event.current.GetTypeForControl(controlId); switch (eventType) { case EventType.Repaint: { var atlasRaw = atlasRawProp.objectReferenceValue as AtlasRaw; var spriteName = spriteNameProp.stringValue; var nameLabel = new GUIContent(atlasRaw != null && spriteName != null ? atlasRaw.name + "/" + spriteName : "None (Sprite)"); EditorStyles.objectField.Draw(tempRect, nameLabel, controlId); break; } case EventType.MouseDown: { EditorGUIUtility.editingTextField = false; if (tempRect.Contains(Event.current.mousePosition)) { if (GUI.enabled) { var targetObjects = atlasRawProp.serializedObject.targetObjects; var atlasRawPropPath = atlasRawProp.propertyPath; var spriteNamePropPath = spriteNameProp.propertyPath; var spriteDirtyPropPath = prop.FindPropertyRelative("m_SpriteDirty").propertyPath; var selector = AtlasSpriteView.Display(); selector.SetInitSprite(atlasRawProp.objectReferenceValue as AtlasRaw, spriteNameProp.stringValue); selector.onSelectSprite = (a, s) => { var sobj = new SerializedObject(targetObjects); sobj.FindProperty(atlasRawPropPath).objectReferenceValue = a; sobj.FindProperty(spriteNamePropPath).stringValue = s; sobj.FindProperty(spriteDirtyPropPath).boolValue = true; sobj.ApplyModifiedProperties(); }; Event.current.Use(); GUIUtility.ExitGUI(); } } break; } } } else { tempRect.width = startWidth - (tempRect.x - startX); SerializedProperty spriteProp = prop.FindPropertyRelative("m_Sprite"); EditorGUI.PropertyField(tempRect, spriteProp, GUIContent.none); } }
public override void OnGUI(Rect rect) { // Escape closes the window if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { editorWindow.Close(); GUIUtility.ExitGUI(); } Rect headerRect = GUILayoutUtility.GetRect(20, 10000, k_HeaderHeight, k_HeaderHeight); EditorGUI.DrawRect(headerRect, headerBgColor); float labelSize = EditorStyles.boldLabel.CalcSize(Styles.instanceLabel).x; headerRect.height = EditorGUIUtility.singleLineHeight; Rect labelRect = new Rect(headerRect.x + k_HeaderLeftMargin, headerRect.y, labelSize, headerRect.height); Rect contentRect = headerRect; contentRect.xMin = labelRect.xMax; GUI.Label(labelRect, Styles.instanceLabel, Styles.boldRightAligned); GUI.Label(contentRect, m_InstanceContent, EditorStyles.boldLabel); labelRect.y += EditorGUIUtility.singleLineHeight; contentRect.y += EditorGUIUtility.singleLineHeight; GUI.Label(labelRect, Styles.contextLabel, Styles.boldRightAligned); GUI.Label(contentRect, m_StageContent, EditorStyles.boldLabel); GUILayout.Space(k_TreeViewPadding.top); // If we know there are no overrides and thus no meaningful actions we just show that and nothing more. if (!IsShowingActionButton()) { EditorGUILayout.LabelField("No Overrides"); return; } // Display tree view and/or instructions related to it. if (HasMultiSelection()) { if (m_InvalidComponentOnAsset || m_InvalidComponentOnInstance || m_ModelPrefab || m_Immutable) { EditorGUILayout.HelpBox(Styles.infoMultipleNoApply.text, MessageType.Info); } else { EditorGUILayout.HelpBox(Styles.infoMultiple.text, MessageType.Info); } } else { if (m_Disconnected) { EditorGUILayout.HelpBox(Styles.warningDisconnected.text, MessageType.Warning); } else if (m_AnyOverrides) { Rect treeViewRect = GUILayoutUtility.GetRect(100, 1000, 0, 1000); m_TreeView.OnGUI(treeViewRect); // Display info message telling user they can click on individual items for more detailed actions. if (m_ModelPrefab) { EditorGUILayout.HelpBox(Styles.infoModel.text, MessageType.Info); } else if (m_Immutable || m_InvalidComponentOnInstance) { EditorGUILayout.HelpBox(Styles.infoNoApply.text, MessageType.Info); } else { EditorGUILayout.HelpBox(Styles.infoDefault.text, MessageType.Info); } } if (IsShowingApplyWarning()) { // Display warnings about edge cases that make it impossible to apply. // Model Prefabs are not an edge case and not needed to warn about so it's // not included here but rather combined into the info message above. if (m_InvalidComponentOnAsset) { EditorGUILayout.HelpBox(Styles.warningInvalidAsset.text, MessageType.Warning); } else if (m_InvalidComponentOnInstance) { EditorGUILayout.HelpBox(Styles.warningInvalidInstance.text, MessageType.Warning); } else { EditorGUILayout.HelpBox(Styles.warningImmutable.text, MessageType.Warning); } } } // Display action buttons (Revert All and Apply All) GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); using (new EditorGUI.DisabledScope(m_InvalidComponentOnAsset)) { if (m_TreeView != null && m_TreeView.GetSelection().Count > 1) { if (GUILayout.Button(m_RevertSelectedContent, GUILayout.Width(m_ButtonWidth))) { if (OperateSelectedOverrides(PrefabUtility.OverrideOperation.Revert)) { RefreshStatus(); // We don't close the window even if there are no more overrides left. // We want to diplay explicit confirmation, since it's not a given outcome // when using Revert Selected. Only Revert All button closes the window. } } using (new EditorGUI.DisabledScope(m_Immutable || m_InvalidComponentOnInstance)) { if (GUILayout.Button(m_ApplySelectedContent, GUILayout.Width(m_ButtonWidth))) { if (OperateSelectedOverrides(PrefabUtility.OverrideOperation.Apply)) { RefreshStatus(); // We don't close the window even if there are no more overrides left. // We want to diplay explicit confirmation, since it's not a given outcome // when using Apply Selected. Only Apply All button closes the window. } } } } else { if (GUILayout.Button(m_RevertAllContent, GUILayout.Width(m_ButtonWidth))) { if (RevertAll() && editorWindow != null) { editorWindow.Close(); GUIUtility.ExitGUI(); } } using (new EditorGUI.DisabledScope(m_Immutable || m_InvalidComponentOnInstance)) { if (GUILayout.Button(m_ApplyAllContent, GUILayout.Width(m_ButtonWidth))) { if (ApplyAll() && editorWindow != null) { editorWindow.Close(); GUIUtility.ExitGUI(); } } } } } GUILayout.EndHorizontal(); }
private void Exit() { Close(); GUIUtility.ExitGUI(); }
private void CloseWindow() { base.Close(); GUI.changed = true; GUIUtility.ExitGUI(); }
private void OnGUI() { EditorGUIUtility.labelWidth = 150; // lang Getter.OnGuiSelectLang(); _tab = TabBar.OnGUI(_tab, _tabButtonStyle, _tabButtonSize); switch (_tab) { case Tabs.MeshSeparator: EditorGUILayout.TextField(MeshProcessingMessages.MESH_SEPARATOR.Msg()); break; case Tabs.MeshIntegrator: EditorGUILayout.TextField(MeshProcessingMessages.MESH_INTEGRATOR.Msg()); break; case Tabs.StaticMeshIntegrator: EditorGUILayout.TextField(MeshProcessingMessages.STATIC_MESH_INTEGRATOR.Msg()); break; } EditorGUILayout.LabelField(MeshProcessingMessages.TARGET_OBJECT.Msg()); _exportTarget = (GameObject)EditorGUILayout.ObjectField(_exportTarget, typeof(GameObject), true); if (_exportTarget == null && MeshUtility.IsGameObjectSelected()) { _exportTarget = Selection.activeObject as GameObject; } // Create Other Buttons { GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Process", GUILayout.MinWidth(100))) { switch (_tab) { case Tabs.MeshSeparator: _isInvokeSuccess = InvokeWizardUpdate("MeshSeparator"); break; case Tabs.MeshIntegrator: _isInvokeSuccess = InvokeWizardUpdate("MeshIntegrator"); break; case Tabs.StaticMeshIntegrator: _isInvokeSuccess = InvokeWizardUpdate("StaticMeshIntegrator"); break; } if (_isInvokeSuccess) { Close(); GUIUtility.ExitGUI(); } } GUI.enabled = true; GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } }
internal void OnGUI() { if (IconSelector.m_Styles == null) { IconSelector.m_Styles = new IconSelector.Styles(); } if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { this.CloseWindow(); } Texture2D texture2D = EditorGUIUtility.GetIconForObject(this.m_TargetObject); bool flag = false; if (Event.current.type == EventType.Repaint) { texture2D = this.ConvertLargeIconToSmallIcon(texture2D, ref flag); } Event current = Event.current; EventType type = current.type; GUI.BeginGroup(new Rect(0f, 0f, base.position.width, base.position.height), IconSelector.m_Styles.background); this.DoTopSection(texture2D != null); GUILayout.Space(22f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(1f); GUI.enabled = false; GUILayout.Label("", IconSelector.m_Styles.seperator, new GUILayoutOption[0]); GUI.enabled = true; GUILayout.Space(1f); GUILayout.EndHorizontal(); GUILayout.Space(3f); if (this.m_ShowLabelIcons) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(6f); for (int i = 0; i < this.m_LabelIcons.Length / 2; i++) { this.DoButton(this.m_LabelIcons[i], texture2D, true); } GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(6f); for (int j = this.m_LabelIcons.Length / 2; j < this.m_LabelIcons.Length; j++) { this.DoButton(this.m_LabelIcons[j], texture2D, true); } GUILayout.EndHorizontal(); GUILayout.Space(3f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(1f); GUI.enabled = false; GUILayout.Label("", IconSelector.m_Styles.seperator, new GUILayoutOption[0]); GUI.enabled = true; GUILayout.Space(1f); GUILayout.EndHorizontal(); GUILayout.Space(3f); } GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(9f); for (int k = 0; k < this.m_SmallIcons.Length / 2; k++) { this.DoButton(this.m_SmallIcons[k], texture2D, false); } GUILayout.Space(3f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(9f); for (int l = this.m_SmallIcons.Length / 2; l < this.m_SmallIcons.Length; l++) { this.DoButton(this.m_SmallIcons[l], texture2D, false); } GUILayout.Space(3f); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f); bool flag2 = false; int controlID = GUIUtility.GetControlID(IconSelector.s_HashIconSelector, FocusType.Keyboard); if (GUILayout.Button(EditorGUIUtility.TempContent("Other..."), new GUILayoutOption[0])) { GUIUtility.keyboardControl = controlID; flag2 = true; } GUI.backgroundColor = new Color(1f, 1f, 1f, 1f); GUI.EndGroup(); if (flag2) { ObjectSelector.get.Show(this.m_TargetObject, typeof(Texture2D), null, false); ObjectSelector.get.objectSelectorID = controlID; GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f); current.Use(); GUIUtility.ExitGUI(); } if (type == EventType.ExecuteCommand) { string commandName = current.commandName; if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == controlID && GUIUtility.keyboardControl == controlID) { Texture2D icon = ObjectSelector.GetCurrentObject() as Texture2D; EditorGUIUtility.SetIconForObject(this.m_TargetObject, icon); GUI.changed = true; current.Use(); } } }
public override void OnInspectorGUI() { serializedObject.Update(); var settings = target as AssetbundleBuildSettings; list.DoLayoutList(); bool allowBuild = true; if (!settings.IsValid()) { GUILayout.Label("Duplicate or Empty BundleName detected"); allowBuild = false; } GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_AutoCreateSharedBundles); if (allowBuild && GUILayout.Button("Get Expected Sharedbundle List")) { AssetbundleBuilder.WriteExpectedSharedBundles(settings); GUIUtility.ExitGUI(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_RemoteOutputPath); if (GUILayout.Button("Open", GUILayout.ExpandWidth(false))) { EditorUtility.RevealInFinder(Utility.CombinePath(settings.RemoteOutputPath, EditorUserBuildSettings.activeBuildTarget.ToString())); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_LocalOutputPath); if (GUILayout.Button("Open", GUILayout.ExpandWidth(false))) { EditorUtility.RevealInFinder(Utility.CombinePath(settings.LocalOutputPath, EditorUserBuildSettings.activeBuildTarget.ToString())); } GUILayout.EndHorizontal(); EditorGUILayout.PropertyField(m_RemoteURL); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_EmulateBundle); EditorGUILayout.PropertyField(m_EmulateUseRemoteFolder); EditorGUILayout.PropertyField(m_CleanCache); EditorGUILayout.PropertyField(m_ForceRebuld); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_UseCacheServer); if (m_UseCacheServer.boolValue) { EditorGUILayout.PropertyField(m_CacheServerHost); EditorGUILayout.PropertyField(m_CacheServerPort); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_UseFtp); if (m_UseFtp.boolValue) { EditorGUILayout.PropertyField(m_FtpHost); EditorGUILayout.PropertyField(m_FtpUser); m_FtpPass.stringValue = EditorGUILayout.PasswordField("Ftp Password", m_FtpPass.stringValue); } GUILayout.Label($"Local Output folder : { settings.LocalOutputPath }"); GUILayout.Label($"Remote Output folder : { settings.RemoteOutputPath }"); serializedObject.ApplyModifiedProperties(); EditorGUI.BeginDisabledGroup(Application.isPlaying); if (AssetbundleBuildSettings.EditorInstance == settings) { EditorGUILayout.BeginHorizontal(); if (allowBuild && GUILayout.Button("Build Remote")) { AssetbundleBuilder.BuildAssetBundles(settings, BuildType.Remote); GUIUtility.ExitGUI(); } if (allowBuild && GUILayout.Button("Build Local")) { AssetbundleBuilder.BuildAssetBundles(settings, BuildType.Local); GUIUtility.ExitGUI(); } EditorGUI.BeginDisabledGroup(!settings.UseFtp); if (allowBuild && GUILayout.Button("Upload(FTP)")) { AssetbundleUploader.UploadAllRemoteFiles(settings); GUIUtility.ExitGUI(); } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); } else { if (GUILayout.Button("Set as active setting")) { AssetbundleBuildSettings.EditorInstance = settings; } } EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
private void CommandBufferGUI() { // Command buffers are not serialized data, so can't get to them through // serialized property (hence no multi-edit). if (targets.Length != 1) { return; } var cam = target as Camera; if (cam == null) { return; } int count = cam.commandBufferCount; if (count == 0) { return; } m_CommandBuffersShown = GUILayout.Toggle(m_CommandBuffersShown, GUIContent.Temp(count + " command buffers"), EditorStyles.foldout); if (!m_CommandBuffersShown) { return; } EditorGUI.indentLevel++; foreach (CameraEvent ce in (CameraEvent[])System.Enum.GetValues(typeof(CameraEvent))) { CommandBuffer[] cbs = cam.GetCommandBuffers(ce); foreach (CommandBuffer cb in cbs) { using (new GUILayout.HorizontalScope()) { // row with event & command buffer information label Rect rowRect = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.miniLabel); rowRect.xMin += EditorGUI.indent; Rect minusRect = GetRemoveButtonRect(rowRect); rowRect.xMax = minusRect.x; GUI.Label(rowRect, string.Format("{0}: {1} ({2})", ce, cb.name, EditorUtility.FormatBytes(cb.sizeInBytes)), EditorStyles.miniLabel); // and a button to remove it if (GUI.Button(minusRect, Styles.iconRemove, Styles.invisibleButton)) { cam.RemoveCommandBuffer(ce, cb); SceneView.RepaintAll(); GameView.RepaintAll(); GUIUtility.ExitGUI(); } } } } // "remove all" button using (new GUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Remove all", EditorStyles.miniButton)) { cam.RemoveAllCommandBuffers(); SceneView.RepaintAll(); GameView.RepaintAll(); } } EditorGUI.indentLevel--; }
public static MMTerrainLayer DrawExpandedGUI(TerrainWrapper wrapper, MMTerrainLayer layer) { bool isInScene = layer != null && string.IsNullOrEmpty(AssetDatabase.GetAssetPath(layer)); EditorGUILayout.BeginHorizontal(); layer = (MMTerrainLayer)EditorGUILayout.ObjectField(isInScene ? "Asset (In-Scene)" : "Asset", layer, typeof(MMTerrainLayer), true); if (layer != null && isInScene && GUILayout.Button(_saveContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { var path = EditorUtility.SaveFilePanel("Save Terrain Layer", "Assets", layer.name, "asset"); if (!string.IsNullOrEmpty(path)) { path = path.Substring(path.LastIndexOf("Assets/", StringComparison.Ordinal)); AssetDatabase.CreateAsset(layer, path); } } EditorGUILayout.EndHorizontal(); if (layer == null) { EditorGUILayout.HelpBox("Snapshot is Null!", MessageType.Error); if (GUILayout.Button("Create Snapshot", EditorStyles.toolbarButton)) { layer = ScriptableObject.CreateInstance <MMTerrainLayer>(); GUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndVertical(); return(layer); } EditorGUILayout.BeginHorizontal(); var previewContent = new GUIContent(GUIResources.EyeOpenIcon, "Preview"); EditorGUILayout.LabelField("Height:", layer.Heights != null ? string.Format("{0}x{1}", layer.Heights.Width, layer.Heights.Height) : "null"); if (layer.Heights != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { DataInspector.SetData(layer.Heights); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.Heights.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorExtensions.Seperator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Splats", layer.SplatData != null ? string.Format("{0}", layer.SplatData.Count) : "null"); if (layer.SplatData != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { List <IDataInspectorProvider> data = new List <IDataInspectorProvider>(); List <object> context = new List <object>(); foreach (var keyValuePair in layer.SplatData) { data.Add(keyValuePair.Value); context.Add(keyValuePair.Key); } DataInspector.SetData(data, context); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.SplatData.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorExtensions.Seperator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Details", layer.DetailData != null ? string.Format("{0}", layer.DetailData.Count) : "null"); if (layer.DetailData != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { List <IDataInspectorProvider> data = new List <IDataInspectorProvider>(); List <object> context = new List <object>(); foreach (var keyValuePair in layer.DetailData) { data.Add(keyValuePair.Value); context.Add(keyValuePair.Key); } DataInspector.SetData(data, context, true); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.DetailData.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorExtensions.Seperator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Trees", layer.Trees != null ? string.Format("{0}", layer.Trees.Count) : "null"); if (layer.Trees != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { Dictionary <object, IDataInspectorProvider> data = new Dictionary <object, IDataInspectorProvider>(); foreach (var tree in layer.Trees) { if (!data.ContainsKey(tree.Prototype)) { data[tree.Prototype] = new PositionList(); } (data[tree.Prototype] as PositionList).Add(tree.Position); } DataInspector.SetData(data.Values.ToList(), data.Keys.ToList(), true); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.Trees.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("➥Removals", layer.TreeRemovals != null ? string.Format("{0}", layer.TreeRemovals.Count) : "null"); if (layer.TreeRemovals != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { Dictionary <object, IDataInspectorProvider> data = new Dictionary <object, IDataInspectorProvider>(); var compoundTrees = wrapper.GetCompoundTrees(layer, false); compoundTrees.AddRange(layer.Trees); foreach (var guid in layer.TreeRemovals) { MadMapsTreeInstance tree = null; foreach (var t in compoundTrees) { if (t.Guid == guid) { tree = t; break; } } if (tree == null) { Debug.LogError("Couldn't find tree removal " + guid, layer); continue; } if (!data.ContainsKey(tree.Prototype)) { data[tree.Prototype] = new PositionList(); } (data[tree.Prototype] as PositionList).Add(tree.Position); } DataInspector.SetData(data.Values.ToList(), data.Keys.ToList(), true); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.TreeRemovals.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorExtensions.Seperator(); #if VEGETATION_STUDIO EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Vegetation Studio", layer.VSInstances != null ? string.Format("{0}", layer.VSInstances.Count) : "null"); if (layer.VSInstances != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { Dictionary <object, IDataInspectorProvider> data = new Dictionary <object, IDataInspectorProvider>(); foreach (var tree in layer.VSInstances) { if (!data.ContainsKey(tree.VSID)) { data[tree.VSID] = new PositionList(); } (data[tree.VSID] as PositionList).Add(tree.Position); } DataInspector.SetData(data.Values.ToList(), data.Keys.ToList(), true); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.VSInstances.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("➥Removals", layer.VSRemovals != null ? string.Format("{0}", layer.VSRemovals.Count) : "null"); if (layer.VSRemovals != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { Dictionary <object, IDataInspectorProvider> data = new Dictionary <object, IDataInspectorProvider>(); var compoundVS = wrapper.GetCompoundVegetationStudioData(layer, false); compoundVS.AddRange(layer.VSInstances); foreach (var guid in layer.VSRemovals) { VegetationStudioInstance vsInstance = null; foreach (var t in compoundVS) { if (t.Guid == guid) { vsInstance = t; break; } } if (vsInstance == null) { Debug.LogError("Couldn't find VS removal " + guid, layer); continue; } if (!data.ContainsKey(vsInstance.VSID)) { data[vsInstance.VSID] = new PositionList(); } (data[vsInstance.VSID] as PositionList).Add(vsInstance.Position); } DataInspector.SetData(data.Values.ToList(), data.Keys.ToList(), true); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.VSRemovals.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorExtensions.Seperator(); #endif EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Objects", layer.Objects != null ? string.Format("{0}", layer.Objects.Count) : "null"); if (layer.Objects != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { Dictionary <object, IDataInspectorProvider> data = new Dictionary <object, IDataInspectorProvider>(); foreach (var obj in layer.Objects) { if (!data.ContainsKey(obj.Prefab)) { data[obj.Prefab] = new PositionList(); } (data[obj.Prefab] as PositionList).Add(obj.Position); } DataInspector.SetData(data.Values.ToList(), data.Keys.ToList(), true); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.Objects.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("➥Removals", layer.ObjectRemovals != null ? string.Format("{0}", layer.ObjectRemovals.Count) : "null"); if (layer.ObjectRemovals != null && GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { Dictionary <object, IDataInspectorProvider> data = new Dictionary <object, IDataInspectorProvider>(); var compoundObjs = wrapper.GetCompoundObjects(layer, false); compoundObjs.AddRange(layer.Objects); foreach (var guid in layer.ObjectRemovals) { WorldStamps.PrefabObjectData?obj = null; foreach (var t in compoundObjs) { if (t.Guid == guid) { obj = t; break; } } if (obj == null) { Debug.LogError("Couldn't find object removal " + guid, layer); continue; } if (!data.ContainsKey(obj.Value.Prefab)) { data[obj.Value.Prefab] = new PositionList(); } (data[obj.Value.Prefab] as PositionList).Add(obj.Value.Position); } DataInspector.SetData(data.Values.ToList(), data.Keys.ToList(), true); } if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.ObjectRemovals.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorExtensions.Seperator(); EditorGUILayout.BeginHorizontal(); bool hasStencil = layer.Stencil != null && layer.Stencil.Width > 0 && layer.Stencil.Height > 0;; EditorGUILayout.LabelField("Stencil" + (hasStencil ? "" : " (null)"), layer.Stencil != null ? string.Format("{0}", string.Format("{0}x{1}", layer.Stencil.Width, layer.Stencil.Height)) : "null"); GUI.enabled = hasStencil; if (GUILayout.Button(EditorGUIUtility.IconContent("Terrain Icon"), EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { TerrainWrapperGUI.StencilLayerDisplay = layer; } if (GUILayout.Button(previewContent, EditorStyles.label, GUILayout.Width(20), GUILayout.Height(16))) { DataInspector.SetData(layer.Stencil); } GUI.enabled = true; if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)) && EditorUtility.DisplayDialog("Really Clear?", "", "Yes", "No")) { layer.Stencil.Clear(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } EditorGUILayout.EndHorizontal(); EditorExtensions.Seperator(); EditorGUILayout.LabelField("Layer Commands", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Capture From Terrain")) { if (EditorUtility.DisplayDialog(string.Format("Capture Layer {0} from current Terrain?", layer.name), "This will clear any existing data!", "Yes", "No")) { layer.SnapshotTerrain(wrapper.Terrain); EditorUtility.SetDirty(layer); EditorUtility.SetDirty(wrapper.Terrain); EditorSceneManager.MarkAllScenesDirty(); AssetDatabase.SaveAssets(); EditorUtility.SetDirty(layer); EditorGUIUtility.ExitGUI(); return(layer); } } EditorGUILayout.Space(); if (GUILayout.Button("Apply To Terrain")) { if (wrapper.PrepareApply()) { layer.WriteToTerrain(wrapper); wrapper.FinaliseApply(); EditorUtility.SetDirty(layer); EditorSceneManager.MarkAllScenesDirty(); EditorGUIUtility.ExitGUI(); return(layer); } } EditorGUILayout.Space(); if (GUILayout.Button("Clear Layer")) { if (EditorUtility.DisplayDialog(string.Format("Clear Layer {0}?", layer.name), "This will clear any existing data!", "Yes", "No")) { layer.Clear(wrapper); EditorUtility.SetDirty(wrapper.Terrain); EditorUtility.SetDirty(layer); EditorSceneManager.MarkAllScenesDirty(); EditorGUIUtility.ExitGUI(); return(layer); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); return(layer); }
private void CloseWindow() { Close(); GUIUtility.ExitGUI(); }
private void OnGuiToolbarServers() { // Server label var labelContent = new GUIContent { text = " Server" }; var labelStyle = new GUIStyle(EditorStyles.label) { margin = new RectOffset(1, 0, 3, 0) }; var labelRect = GUILayoutUtility.GetRect(labelContent, labelStyle, GUILayout.Width(48f)); EditorGUI.LabelField(labelRect, labelContent, labelStyle); var accountContent = new GUIContent { text = CurrentAccount == null ? "None" : $"{CurrentAccount.login}@{CurrentAccount.host}" }; // Account dropdown list const float toolbarDropDownWidth = 240f; var accountRect = GUILayoutUtility.GetRect( accountContent, EditorStyles.toolbarDropDown, GUILayout.Width(toolbarDropDownWidth) ); var accountToolbarStyle = new GUIStyle(EditorStyles.toolbarDropDown) { padding = new RectOffset(5, 5, 0, 0) }; if (EditorGUI.DropdownButton(accountRect, accountContent, FocusType.Passive, accountToolbarStyle)) { var rect = GUILayoutUtility.GetLastRect(); rect = new Rect(rect.x + 48, rect.y + 20, rect.width, rect.height); // PopupWindow.Show(rect, new SceneRenderModeWindow(this)); PopupWindow.Show( rect, new OpenLoaderAccountsPopup( this, toolbarDropDownWidth, _settings.SavedAccounts, CurrentAccount, _settings.SavedAccountsLimit ) ); GUIUtility.ExitGUI(); } // Free space EditorGUILayout.Space(); // Connection button if (CurrentAccount != null) { var connectionText = _connectionToggleState ? "Disconnect" : "Connect"; var connectionToggleContent = new GUIContent { text = connectionText, image = _connectionIcon }; var connectionStyle = new GUIStyle(EditorStyles.toolbarButton) { fixedWidth = 38f + connectionText.Length * 6f, alignment = TextAnchor.MiddleLeft, padding = new RectOffset(5, 5, 0, 0) }; _connectionToggleState = GUILayout.Toggle( _connectionToggleState, connectionToggleContent, connectionStyle ); } // Settings button var settingsToggleContent = new GUIContent { image = _settingsIcon }; var settingsStyle = new GUIStyle(EditorStyles.toolbarButton) { fixedWidth = 24f, margin = new RectOffset(5, 3, 0, 0) }; _settingsToggleState = GUILayout.Toggle(_settingsToggleState, settingsToggleContent, settingsStyle); }
public override void OnInspectorGUI() { if (skipEvent && Event.current.type == EventType.Repaint) { skipEvent = false; return; } SerializedProperty scriptProperty = this.serializedObject.FindProperty("m_Script"); if (scriptProperty == null || scriptProperty.objectReferenceValue != null) { if (doFix) { if (Event.current.type == EventType.Repaint) { Next(); } } else { base.OnInspectorGUI(); } return; } int pbObjectMatches = 0, pbEntityMatches = 0; // Shows a detailed tree view of all the properties in this serializedobject. // GUILayout.Label( SerializedObjectToString(this.serializedObject) ); SerializedProperty iterator = this.serializedObject.GetIterator(); iterator.Next(true); while (iterator.Next(true)) { if (PB_OBJECT_SCRIPT_PROPERTIES.Contains(iterator.name)) { pbObjectMatches++; } if (PB_ENTITY_SCRIPT_PROPERTIES.Contains(iterator.name)) { pbEntityMatches++; } } // If we can fix it, show the help box, otherwise just default inspector it up. if (pbObjectMatches >= 3 || pbEntityMatches >= 3) { EditorGUILayout.HelpBox("Missing Script Reference\n\nProBuilder can automatically fix this missing reference. To fix all references in the scene, click \"Fix All in Scene\". To fix just this one, click \"Reconnect\".", MessageType.Warning); } else { if (doFix) { if (applyDummyScript) { index += .5f; scriptProperty.objectReferenceValue = dummy_monoscript; scriptProperty.serializedObject.ApplyModifiedProperties(); scriptProperty = this.serializedObject.FindProperty("m_Script"); scriptProperty.serializedObject.Update(); } else { unfixable.Add(((Component)target).gameObject); } Next(); GUIUtility.ExitGUI(); return; } else { base.OnInspectorGUI(); } return; } GUI.backgroundColor = Color.green; if (!doFix) { if (GUILayout.Button("Fix All in Scene")) { FixAllScriptReferencesInScene(); return; } } GUI.backgroundColor = Color.cyan; if ((doFix && Event.current.type == EventType.Repaint) || GUILayout.Button("Reconnect")) { if (pbObjectMatches >= 3) // only increment for pb_Object otherwise the progress bar will fill 2x faster than it should { index++; } else { // Make sure that pb_Object is fixed first if we're automatically cycling objects. if (doFix && ((Component)target).gameObject.GetComponent <pb_Object>() == null) { return; } } if (!doFix) { Undo.RegisterCompleteObjectUndo(target, "Fix missing reference."); } // Debug.Log("Fix: " + (pbObjectMatches > 2 ? "pb_Object" : "pb_Entity") + " " + ((Component)target).gameObject.name); scriptProperty.objectReferenceValue = pbObjectMatches >= 3 ? pb_monoscript : pe_monoscript; scriptProperty.serializedObject.ApplyModifiedProperties(); scriptProperty = this.serializedObject.FindProperty("m_Script"); scriptProperty.serializedObject.Update(); if (doFix) { Next(); } GUIUtility.ExitGUI(); } GUI.backgroundColor = Color.white; }