public static LabelField ( |
||
label | Label in front of the label field. | |
return | void |
public override void OnGUI(Rect rect) { searchText = searchField.OnGUI(searchText); scrollPosition = EGL.BeginScrollView(scrollPosition); foreach (var type in behaviourTypes) { if (type.ToLower().Contains(searchText.ToLower())) { EGL.BeginHorizontal(); EGL.LabelField(type, GL.Width(140)); if (GL.Button("Add", GL.Width(40))) { var instance = (StateBehaviour)ScriptableObject.CreateInstance(type); instance.name = type; instance.hideFlags = HideFlags.HideInHierarchy; list.Add(instance); AssetDatabase.AddObjectToAsset(instance, profile); AssetDatabase.SaveAssets(); editorWindow.Close(); } EGL.EndHorizontal(); } } EGL.EndScrollView(); }
void OnGUI() { EGL.LabelField("Generated texture", EditorStyles.boldLabel); EGL.LabelField("Show channels:"); EGL.BeginHorizontal(); _c[3] = GUILayout.Toggle(_c[3], "A"); EG.BeginDisabledGroup(_c[3]); _c[0] = GUILayout.Toggle(_c[0], "R"); _c[1] = GUILayout.Toggle(_c[1], "G"); _c[2] = GUILayout.Toggle(_c[2], "B"); EG.EndDisabledGroup(); EGL.EndHorizontal(); EGL.LabelField("Zoom"); zoom = EGL.Slider(zoom, 0.2f, 3f); EGL.LabelField("Slice"); slice = EGL.Slider(slice, 0f, 1f); Rect r_tex = EGL.BeginVertical(GUILayout.ExpandHeight(true)); r_tex.height = r_tex.width = Mathf.Min(r_tex.height, r_tex.width); if (texture) { previewMaterial.SetFloat("_Zoom", zoom); previewMaterial.SetFloat("_Slice", slice); previewMaterial.SetVector("_Channels", ChannelVector()); EG.DrawPreviewTexture(r_tex, texture, previewMaterial); } EGL.EndVertical(); }
private void OnGUI() { EGL.LabelField("Use Settings"); settings = EGL.ObjectField(settings, typeof(ImportSettings), false) as ImportSettings; EGL.Space(); if (settings && CenteredButton("OK")) { var reference = new MetaSpriteImportData { metaSpriteSettingsGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(settings)) }; foreach (var path in assetPaths) { var import = AssetImporter.GetAtPath(path); import.userData = JsonUtility.ToJson(reference); import.SaveAndReimport(); } finishedAction(settings); this.Close(); } if (CenteredButton("Cancel")) { this.Close(); } }
void OnGUI() { EGL.LabelField("Use Settings"); settings = (ImportSettings)EGL.ObjectField(settings, typeof(ImportSettings), false); EGL.Space(); if (settings && CenteredButton("OK")) { foreach (var path in paths) { var instance = ScriptableObject.CreateInstance <ImportSettingsReference>(); instance.settings = settings; Directory.CreateDirectory(Path.GetDirectoryName(path)); AssetDatabase.CreateAsset(instance, path); } finishedAction(settings); this.Close(); } if (CenteredButton("Cancel")) { this.Close(); } }
private void OnGUI() { if (EntityManager == null) { EditorGUILayout.HelpBox("please set EntityManager -> BuffDebugWindow.EntityManager", MessageType.Warning); return; } var entitys = EntityManager.Entitys; EditorGUILayout.LabelField("Entity count:" + entitys.Count); EditorGUI.indentLevel++; _pos = EditorGUILayout.BeginScrollView(_pos, "box"); { foreach (var entity in entitys) { EditorGUILayout.LabelField($"{entity} Buff Count:" + EntityManager.GetAllBuff(entity).Count()); } } EditorGUILayout.EndScrollView(); EditorGUI.indentLevel--; Repaint(); }
void DrawHyperLinkInputSection(SP dialog) { if (!isHyperlinkButtonClicked) { return; } if (string.IsNullOrEmpty(hyperlinkSavedText) || hyperLinkSavedStartIndex < 0 || hyperlinkSavedEndIndex < 0) { return; } EGL.BeginVertical(ES.helpBox); EGL.LabelField("Selected Text:", ES.miniBoldLabel); EGL.LabelField(hyperlinkSavedText, ES.helpBox); EGL.LabelField("Link:", ES.miniBoldLabel); savedLink = EGL.TextField(string.IsNullOrEmpty(savedLink) ? HyperlinkPrefix : savedLink); if (GUILayout.Button("Insert hyperlink")) { string newText = string.Format("<a href=\"{0}\">{1}</a>", savedLink, hyperlinkSavedText); ReplaceTextInProperty(dialog, hyperLinkSavedStartIndex, hyperlinkSavedEndIndex, newText); isHyperlinkButtonClicked = false; } EGL.EndVertical(); EGL.Space(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var tree = (BehaviourTree)target; var script = tree.source; if (script) { if (script.notCompiled) { EGL.HelpBox("Script is not compiled.", MessageType.Error); } if (script.notUpToDate) { EGL.HelpBox("Script is not up to date.", MessageType.Warning); } if (script.compileOkay) { EGL.HelpBox("Script is compiled and up to date.", MessageType.Info); } if (GL.Button("Compile")) { script.Compile(); } } if (Application.isPlaying) { EGL.Space(); EGL.LabelField("Conditions"); GUI.enabled = false; foreach (var cond in tree.blackboard) { var k = cond.Key; var v = cond.Value; if (v is float) { EGL.FloatField(k, (float)v); } else if (v is int) { EGL.IntField(k, (int)v); } else if (v is bool) { EGL.Toggle(k, (bool)v); } else if (v is string) { EGL.TextField(k, (string)v); } } GUI.enabled = true; Repaint(); } }
public static IntRange FrameRangeInput(string text, IntRange range) { EGL.BeginHorizontal(); EGL.PrefixLabel(text); range.from = EGL.IntField(range.from); EGL.LabelField("->", GL.Width(30)); range.to = EGL.IntField(range.to); EGL.EndHorizontal(); return(range); }
void DrawPrivacyConsentDialogSettingsGUI() { DrawUppercaseSection("CONSENT_DIALOG_COMPOSER_FOLDOUT_KEY", "DEFAULT CONSENT DIALOG COMPOSER", () => { // Dialog title. EGL.Space(); EGL.LabelField("Dialog Title", ES.boldLabel); EGL.PropertyField(PrivacyProperties.consentDialogTitle.property); // Draw the main content. EGL.Space(); EGL.LabelField("Main Content", ES.boldLabel); EGL.LabelField(ContentDescription, ES.helpBox); DrawConsentDialogContentEditor(); // Draw the toggles array. SP togglesArray = PrivacyProperties.consentDialogToggles.property; if (togglesArray.arraySize < MinTogglesCount) { togglesArray.arraySize += MinTogglesCount - togglesArray.arraySize; } EGL.Space(); EGL.LabelField("Toggle List", ES.boldLabel); EGL.LabelField(TogglesArrayDescription, ES.helpBox); togglesFoldout = DrawResizableArray(togglesArray, togglesFoldout, "Toggles", DrawToggleArrayElement, UpdateNewTogglePropertyInfo); // Draw the buttons array. SP buttonsArray = PrivacyProperties.consentDialogActionButtons.property; if (buttonsArray.arraySize < MinActionButtonsCount) { buttonsArray.arraySize += MinActionButtonsCount - buttonsArray.arraySize; } EGL.Space(); EGL.LabelField("Button List", ES.boldLabel); EGL.LabelField(ButtonsArrayDescription, ES.helpBox); buttonsFoldout = DrawResizableArray(buttonsArray, buttonsFoldout, "Buttons", DrawActionButtonArrayElement, UpdateNewButtonPropertyInfo); // Preview button. EGL.Space(); EGL.LabelField("Preview", ES.boldLabel); EGL.LabelField(PreviewSectionDescription, ES.helpBox); if (GUILayout.Button("Run Preview Scene") && !EditorApplication.isPlaying) { if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { EditorSceneManager.OpenScene(EM_Constants.DemoPrivacyScenePath); EditorApplication.isPlaying = true; } } }); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); afterburner = target as Afterburner; EGL.LabelField("Is Active?", afterburner.Burning.ToString()); EGL.LabelField("Is On Cooldown?", afterburner.IsOnCooldown.ToString()); ShowButtons(); }
private void StartGUI(string name) { Rect r = EGL.BeginVertical( ); GL.Space(3); EGL.BeginHorizontal(); GUI.backgroundColor = Color.black * 2; GUI.contentColor = Color.white; GUI.Box(r, GUIContent.none); GUI.contentColor = Color.white * 10; EGL.LabelField(" " + name, EditorStyles.boldLabel, GL.Width(85)); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var rt = (TransitionRuntime)target; if (Application.isPlaying) { foreach (var p in rt.paramTable) { if (p.type == ParamType.Bool) { EGL.Toggle(p.name + "(bool)", p.boolValue); } else if (p.type == ParamType.Trigger) { EGL.Toggle(p.name + "(trigger)", p.boolValue); } else if (p.type == ParamType.Float) { EGL.LabelField(p.name + " (float)", p.floatValue.ToString()); } else if (p.type == ParamType.Int) { EGL.LabelField(p.name + "(int)", p.intValue.ToString()); } } Repaint(); } else { if (GUILayout.Button("Edit", GUILayout.MaxWidth(150))) { var instance = EditorWindow.GetWindow <TransitionProfileEditor>(); instance.titleContent = new GUIContent("Transition Prof."); instance.BeginEdit(rt.profile); } } }
public override void OnInspectorGUI() { if (play) { EGL.LabelField("Play mode", gm.playMode.ToString()); EGL.LabelField("Gen. seed", gm.generatorSeed.ToString()); } else { gm.playMode = (PlayMode)EGL.EnumPopup("Play mode", gm.playMode); if (gm.playMode == PlayMode.RandomDungeon) { gm.generatorSeed = EGL.DelayedIntField("Gen. seed", gm.generatorSeed); if (GL.Button("Random seed")) { gm.generatorSeed = new Random().Next(); } } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var engine = target as Engine; if (Application.isPlaying == false) { return; } EGL.LabelField("Speed: " + engine.Speed); EGL.Space(); ShowButtons(engine); EGL.Space(); EGL.LabelField("Pitch: " + engine.Pitch); EGL.LabelField("Yaw: " + engine.Yaw); EGL.LabelField("Roll: " + engine.Roll); engine.Strafe = EGL.Slider("Strafe", engine.Strafe, -1, 1); engine.Throttle = EGL.Slider("Throttle", engine.Throttle, 0, 1); }
public override void OnInspectorGUI() { field = (AsteroidField)target; EGL.LabelField("Settings", EditorStyles.boldLabel); field.hideFlags = (HideFlags)EGL.EnumPopup("Hide Flags", field.hideFlags); field.desiredAsteroids = EGL.IntField("Desired Asteroids", field.desiredAsteroids); EGL.Space(); EGL.LabelField("GameObject", EditorStyles.boldLabel); ShowGameObjectInformation(); EGL.Space(); EGL.LabelField("Radius", EditorStyles.boldLabel); ShowRadiusInfromation(); EGL.Space(); EGL.LabelField("Scale", EditorStyles.boldLabel); ShowScaleInformation(); EGL.Space(); ShowButtons(); }
void OnGUI() { EGL.LabelField("3D Texture properties", EditorStyles.boldLabel); int new_size = EGL.IntField("Resolution", data.size); new_size = new_size <= 512 ? new_size : 512; new_size = new_size >= 8 ? new_size : 8; data.size = new_size; EGL.LabelField("Worley noise"); data.freqs[0] = EGL.FloatField("Frequency", data.freqs[0]); data.octaves[0] = EGL.IntField("Octaves", data.octaves[0]); bool inv = EGL.Toggle("Invert", data.inverts[0] > 0); data.inverts[0] = inv ? 1 : 0; if (GUILayout.Button("Generate")) { CreateTexture(); } EGL.HelpBox(status, MessageType.None, true); if (GUILayout.Button("Preview")) { CloudPreviewer.ShowTexture(texture); } EGL.BeginHorizontal(); assetName = EGL.TextField("Asset name:", assetName); if (GUILayout.Button("Save")) { AssetDatabase.CreateAsset(texture, "Assets/" + assetName + ".asset"); } EGL.EndHorizontal(); }
public override void OnPaintInspectorGUI() { EditorGUI.BeginChangeCheck(); randomBrush.pickRandomTiles = EditorGUILayout.Toggle("Pick Random Tiles", randomBrush.pickRandomTiles); using (new EditorGUI.DisabledScope(!randomBrush.pickRandomTiles)) { randomBrush.addToRandomTiles = EditorGUILayout.Toggle("Add To Random Tiles", randomBrush.addToRandomTiles); } EditorGUI.BeginChangeCheck(); randomBrush.randomTileSetSize = EditorGUILayout.Vector3IntField("Tile Set Size", randomBrush.randomTileSetSize); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < randomBrush.randomTileSets.Length; ++i) { int sizeCount = randomBrush.randomTileSetSize.x * randomBrush.randomTileSetSize.y * randomBrush.randomTileSetSize.z; randomBrush.randomTileSets[i].randomTiles = new TileBase[sizeCount]; } } int randomTileSetCount = EditorGUILayout.DelayedIntField("Number of Tiles", randomBrush.randomTileSets != null ? randomBrush.randomTileSets.Length : 0); if (randomTileSetCount < 0) { randomTileSetCount = 0; } if (randomBrush.randomTileSets == null || randomBrush.randomTileSets.Length != randomTileSetCount) { Array.Resize(ref randomBrush.randomTileSets, randomTileSetCount); for (int i = 0; i < randomBrush.randomTileSets.Length; ++i) { int sizeCount = randomBrush.randomTileSetSize.x * randomBrush.randomTileSetSize.y * randomBrush.randomTileSetSize.z; if (randomBrush.randomTileSets[i].randomTiles == null || randomBrush.randomTileSets[i].randomTiles.Length != sizeCount) { randomBrush.randomTileSets[i].randomTiles = new TileBase[sizeCount]; } } } if (randomTileSetCount > 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Place random tiles."); for (int i = 0; i < randomTileSetCount; i++) { EditorGUILayout.LabelField("Tile Set " + (i + 1)); for (int j = 0; j < randomBrush.randomTileSets[i].randomTiles.Length; ++j) { randomBrush.randomTileSets[i].randomTiles[j] = (TileBase)EditorGUILayout.ObjectField("Tile " + (j + 1), randomBrush.randomTileSets[i].randomTiles[j], typeof(TileBase), false, null); } } } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(randomBrush); } }
public override void OnInspectorGUI() { EGL.LabelField("已有道具:"); items = ItemXmlManager.XmlReader.FindItems(); for (int i = 0; i < items.Count; i++) { EGL.BeginHorizontal(); EGL.LabelField(items[i]); if (!tryToAddNewItem && tryToModify == -1) { if (GUILayout.Button("修改")) { tryToModify = i; sm.LoadItemClassInfo(items[tryToModify]); so.Update(); } if (GUILayout.Button("删除")) { sm.DeleteItemClass(items[i]); so.Update(); } } EGL.EndHorizontal(); } if (tryToModify == -1 && tryToAddNewItem == false) { EGL.Separator(); EGL.Separator(); EGL.Separator(); EGL.Separator(); if (GUILayout.Button("添加一个新道具")) { tryToAddNewItem = true; sm.GetNewItemTemplate(); so.Update(); } } if (tryToModify != -1) { tryToAddNewItem = false; EGL.Separator(); EGL.Separator(); EGL.LabelField("类名: " + items[tryToModify]); EGL.PropertyField(newItemName, new GUIContent("道具名字")); EGL.PropertyField(resources, new GUIContent("道具预置体")); EGL.LabelField("该预置体必须处于\"Resource/ItemPrefabs\"文件夹下!"); EGL.BeginHorizontal(); EGL.PropertyField(parameterName, new GUIContent("参数名字"), true); EGL.PropertyField(parameterValue, new GUIContent("参数值"), true); EGL.EndHorizontal(); EGL.BeginHorizontal(); if (GUILayout.Button("应用")) { so.ApplyModifiedProperties(); sm.ModifyItem(items[tryToModify]); so.Update(); tryToModify = -1; } if (GUILayout.Button("取消")) { tryToModify = -1; } EGL.EndHorizontal(); } if (tryToAddNewItem) { EGL.Separator(); EGL.Separator(); EGL.PropertyField(newItemClassName, new GUIContent("类名")); EGL.PropertyField(newItemName, new GUIContent("道具名字")); EGL.PropertyField(resources, new GUIContent("道具预置体")); EGL.LabelField("该预置体必须处于\"Resource/ItemPrefabs\"文件夹下!"); EGL.BeginHorizontal(); EGL.PropertyField(parameterName, new GUIContent("参数名字"), true); EGL.PropertyField(parameterValue, new GUIContent("参数值"), true); EGL.EndHorizontal(); EGL.BeginHorizontal(); if (GUILayout.Button("应用")) { so.ApplyModifiedProperties(); if (sm.CreateNewItemClass()) { tryToAddNewItem = false; msg = ""; } else { msg = "请先删除重名类!或更改一个新类名"; } } if (GUILayout.Button("取消")) { tryToAddNewItem = false; msg = ""; } EGL.EndHorizontal(); } EGL.LabelField(msg); }
public override void OnInspectorGUI() { if (AssetStoreAssetInspector.styles == null) { AssetStoreAssetInspector.s_SharedAssetStoreAssetInspector = this; AssetStoreAssetInspector.styles = new AssetStoreAssetInspector.Styles(); } AssetStoreAsset firstAsset = AssetStoreAssetSelection.GetFirstAsset(); AssetStoreAsset.PreviewInfo previewInfo = null; if (firstAsset != null) { previewInfo = firstAsset.previewInfo; } if (firstAsset != null) { base.target.name = string.Format("Asset Store: {0}", firstAsset.name); } else { base.target.name = "Asset Store"; } EditorGUILayout.BeginVertical(new GUILayoutOption[0]); bool enabled = GUI.enabled; GUI.enabled = (firstAsset != null && firstAsset.packageID != 0); if (AssetStoreAssetInspector.OfflineNoticeEnabled) { Color color = GUI.color; GUI.color = Color.yellow; GUILayout.Label("Network is offline", new GUILayoutOption[0]); GUI.color = color; } if (firstAsset != null) { string label = (firstAsset.className != null) ? firstAsset.className.Split(new char[] { ' ' }, 2)[0] : ""; bool flag = firstAsset.id == -firstAsset.packageID; if (flag) { label = "Package"; } if (firstAsset.HasLivePreview) { label = firstAsset.Preview.GetType().Name; } EditorGUILayout.LabelField("Type", label, new GUILayoutOption[0]); if (flag) { this.packageInfoShown = true; } else { EditorGUILayout.Separator(); this.packageInfoShown = EditorGUILayout.Foldout(this.packageInfoShown, "Part of package", true); } if (this.packageInfoShown) { EditorGUILayout.LabelField("Name", (previewInfo != null) ? previewInfo.packageName : "-", new GUILayoutOption[0]); EditorGUILayout.LabelField("Version", (previewInfo != null) ? previewInfo.packageVersion : "-", new GUILayoutOption[0]); string label2 = (previewInfo != null) ? ((firstAsset.price == null || !(firstAsset.price != "")) ? "free" : firstAsset.price) : "-"; EditorGUILayout.LabelField("Price", label2, new GUILayoutOption[0]); string label3 = (previewInfo == null || previewInfo.packageRating < 0) ? "-" : (previewInfo.packageRating.ToString() + " of 5"); EditorGUILayout.LabelField("Rating", label3, new GUILayoutOption[0]); EditorGUILayout.LabelField("Size", (previewInfo != null) ? AssetStoreAssetInspector.intToSizeString(previewInfo.packageSize) : "-", new GUILayoutOption[0]); string label4 = (previewInfo == null || previewInfo.packageAssetCount < 0) ? "-" : previewInfo.packageAssetCount.ToString(); EditorGUILayout.LabelField("Asset count", label4, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel("Web page"); bool flag2 = previewInfo != null && previewInfo.packageShortUrl != null && previewInfo.packageShortUrl != ""; bool enabled2 = GUI.enabled; GUI.enabled = flag2; if (GUILayout.Button((!flag2) ? EditorGUIUtility.TempContent("-") : new GUIContent(previewInfo.packageShortUrl, "View in browser"), AssetStoreAssetInspector.styles.link, new GUILayoutOption[0])) { Application.OpenURL(previewInfo.packageShortUrl); } if (GUI.enabled) { EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); } GUI.enabled = enabled2; GUILayout.EndHorizontal(); EditorGUILayout.LabelField("Publisher", (previewInfo != null) ? previewInfo.publisherName : "-", new GUILayoutOption[0]); } if (firstAsset.id != 0) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); string text; if (previewInfo != null && previewInfo.isDownloadable) { text = "Import package"; } else { text = "Buy for " + firstAsset.price; } bool enabled3 = GUI.enabled; bool flag3 = previewInfo != null && previewInfo.buildProgress >= 0f; bool flag4 = previewInfo != null && previewInfo.downloadProgress >= 0f; if (flag3 || flag4 || previewInfo == null) { text = ""; GUI.enabled = false; } if (GUILayout.Button(text, new GUILayoutOption[] { GUILayout.Height(40f), GUILayout.Width(120f) })) { if (previewInfo.isDownloadable) { this.ImportPackage(firstAsset); } else { this.InitiateBuySelected(); } GUIUtility.ExitGUI(); } if (Event.current.type == EventType.Repaint) { Rect lastRect = GUILayoutUtility.GetLastRect(); lastRect.height -= 4f; float width = lastRect.width; lastRect.width = lastRect.height; lastRect.y += 2f; lastRect.x += 2f; if (flag3 || flag4) { lastRect.width = width - lastRect.height - 4f; lastRect.x += lastRect.height; EditorGUI.ProgressBar(lastRect, (!flag4) ? previewInfo.buildProgress : previewInfo.downloadProgress, (!flag4) ? "Building" : "Downloading"); } } GUI.enabled = enabled3; GUILayout.Space(4f); if (GUILayout.Button("Open Asset Store", new GUILayoutOption[] { GUILayout.Height(40f), GUILayout.Width(120f) })) { AssetStoreAssetInspector.OpenItemInAssetStore(firstAsset); GUIUtility.ExitGUI(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); } EditorWrapper previewEditor = this.previewEditor; if (previewEditor != null && firstAsset != null && firstAsset.HasLivePreview) { previewEditor.OnAssetStoreInspectorGUI(); } GUI.enabled = enabled; EditorGUILayout.EndVertical(); }
void DrawControls() { if (m_Manager == null) { return; } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_HostMigrationProperty, m_HostMigrationLabel); EditorGUILayout.PropertyField(m_ShowGUIProperty, m_ShowGUILabel); if (m_Manager.showGUI) { EditorGUILayout.PropertyField(m_OffsetXProperty, m_OffsetXLabel); EditorGUILayout.PropertyField(m_OffsetYProperty, m_OffsetYLabel); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } if (Application.isPlaying) { EditorGUILayout.Separator(); //runtime data EditorGUILayout.LabelField("Disconnected From Host", m_Manager.disconnectedFromHost.ToString()); EditorGUILayout.LabelField("Waiting to become New Host", m_Manager.waitingToBecomeNewHost.ToString()); EditorGUILayout.LabelField("Waitingto Reconnect to New Host", m_Manager.waitingReconnectToNewHost.ToString()); EditorGUILayout.LabelField("Your ConnectionId", m_Manager.oldServerConnectionId.ToString()); EditorGUILayout.LabelField("New Host Address", m_Manager.newHostAddress); if (m_Manager.peers != null) { m_ShowPeers = EditorGUILayout.Foldout(m_ShowPeers, "Peers"); if (m_ShowPeers) { EditorGUI.indentLevel += 1; foreach (var peer in m_Manager.peers) { EditorGUILayout.LabelField("Peer: ", peer.ToString()); } EditorGUI.indentLevel -= 1; } } if (m_Manager.pendingPlayers != null) { m_ShowPlayers = EditorGUILayout.Foldout(m_ShowPlayers, "Pending Players"); if (m_ShowPlayers) { EditorGUI.indentLevel += 1; foreach (var connId in m_Manager.pendingPlayers.Keys) { EditorGUILayout.LabelField("Connection: ", connId.ToString()); EditorGUI.indentLevel += 1; var players = m_Manager.pendingPlayers[connId].players; foreach (var p in players) { EditorGUILayout.ObjectField("Player netId:" + p.netId + " contId:" + p.playerControllerId, p.obj, typeof(GameObject), false); } EditorGUI.indentLevel -= 1; } EditorGUI.indentLevel -= 1; } } } }
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); } }
void ShowSingleImport() { ImporterConfiguration config = LandmassEditorUtilities.Instance.ImportCfg; EGL.BeginVertical(); { EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Target Terrain"); _singleTargetTerrain = EGL.ObjectField(_singleTargetTerrain, typeof(Terrain), true, GUILayout.Width(240f)) as Terrain; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ----- Heightmap ----- */ GUILayout.Label("Heightmap"); GUILayout.BeginHorizontal(); { EGL.LabelField("Path", _singleHeightmapPath); if (GUILayout.Button("Browse", GUILayout.Width(60f))) { _singleHeightmapPath = EditorUtility.OpenFilePanel("Browse to Heightmap file", _singleHeightmapPath, "r16"); } } GUILayout.EndHorizontal(); GUI.enabled = _singleHeightmapPath != ""; { if (GUILayout.Button("Apply")) { LandmasImporter.ParseHeightmapFileToTerrain( _singleHeightmapPath, _singleTargetTerrain.terrainData, config.HeightFormat, config.HeightmapFlipX, config.HeightmapFlipY ); } } GUI.enabled = true; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ----- Splatmaps ------ */ GUILayout.Label("Splatmap"); _singleSplatmap = EGL.ObjectField(_singleSplatmap, typeof(Texture2D), false, GUILayout.Width(100f), GUILayout.Height(100f)) as Texture2D; EGL.Separator(); GUI.enabled = _singleSplatmap != null && _singleTargetTerrain != null; { if (GUILayout.Button("Apply")) { var splatmap = new float[_singleSplatmap.width, _singleSplatmap.height, 4]; LandmasImporter.TextureToSplatMap( _singleSplatmap, ref splatmap, false, true); LandmasImporter.Instance.NormalizeSplatmap(ref splatmap, config.NormalizationMode); LandmasImporter.Instance.ParseSplatmapToTerrain(splatmap, _singleTargetTerrain.terrainData); } } GUI.enabled = true; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ------ Treemaps ----- */ GUILayout.Label("Treemap"); _singleTreemap = EGL.ObjectField(_singleTreemap, typeof(Texture2D), false, GUILayout.Width(100f), GUILayout.Height(100f)) as Texture2D; GUI.enabled = _singleTreemap != null; { if (GUILayout.Button("Apply")) { LandmasImporter.ParseTreemapTexturesToTerrain(_singleTreemap, _singleTargetTerrain.terrainData); } } GUI.enabled = true; EGL.Separator(); if (GUILayout.Button("Flush Terrain")) { Terrain terrain = Selection.activeGameObject.GetComponent <Terrain>(); if (terrain) { Debug.Log("Flushing Terrain"); terrain.Flush(); } } } EGL.EndVertical(); } EGL.EndVertical(); }
public override void OnInspectorGUI() { if (m_EditorUserSettings != null && !m_EditorUserSettings.targetObject) { LoadEditorUserSettings(); } serializedObject.Update(); // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes // that the editor will only be disabled because of version control locking which may change in the future. var editorEnabled = GUI.enabled; ShowUnityRemoteGUI(editorEnabled); GUILayout.Space(10); bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject(); using (new EditorGUI.DisabledScope(!collabEnabled)) { GUI.enabled = !collabEnabled; GUILayout.Label(Content.versionControl, EditorStyles.boldLabel); ExternalVersionControl selvc = EditorSettings.externalVersionControl; CreatePopupMenuVersionControl(Content.mode.text, vcPopupList, selvc, SetVersionControlSystem); GUI.enabled = editorEnabled && !collabEnabled; } if (collabEnabled) { EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning); } if (VersionControlSystemHasGUI()) { GUI.enabled = true; bool hasRequiredFields = false; if (EditorSettings.externalVersionControl == ExternalVersionControl.Generic || EditorSettings.externalVersionControl == ExternalVersionControl.Disabled) { // no specific UI for these VCS types } else { ConfigField[] configFields = Provider.GetActiveConfigFields(); hasRequiredFields = true; foreach (ConfigField field in configFields) { string newVal; string oldVal = EditorUserSettings.GetConfigValue(field.name); if (field.isPassword) { newVal = EditorGUILayout.PasswordField(field.label, oldVal); if (newVal != oldVal) EditorUserSettings.SetPrivateConfigValue(field.name, newVal); } else { newVal = EditorGUILayout.TextField(field.label, oldVal); if (newVal != oldVal) EditorUserSettings.SetConfigValue(field.name, newVal); } if (field.isRequired && string.IsNullOrEmpty(newVal)) hasRequiredFields = false; } } // Log level popup string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel"); int idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel); if (idx == -1) { logLevel = "notice"; idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel); if (idx == -1) { idx = 0; } logLevel = logLevelPopupList[idx]; EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel); } int newIdx = EditorGUILayout.Popup(Content.logLevel, idx, logLevelPopupList); if (newIdx != idx) { EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower()); } GUI.enabled = editorEnabled; string osState = "Connected"; if (Provider.onlineState == OnlineState.Updating) osState = "Connecting..."; else if (Provider.onlineState == OnlineState.Offline) osState = "Disconnected"; else if (EditorUserSettings.WorkOffline) osState = "Work Offline"; EditorGUILayout.LabelField(Content.status.text, osState); if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason)) { GUI.enabled = false; GUILayout.TextArea(Provider.offlineReason); GUI.enabled = editorEnabled; } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating; if (GUILayout.Button("Connect", EditorStyles.miniButton)) Provider.UpdateSettings(); GUILayout.EndHorizontal(); EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle(Content.automaticAdd, EditorUserSettings.AutomaticAdd); if (Provider.requiresNetwork) { bool workOfflineNew = EditorGUILayout.Toggle(Content.workOffline, EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour if (workOfflineNew != EditorUserSettings.WorkOffline) { // On toggling on show a warning if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel")) { workOfflineNew = false; // User cancelled working offline } EditorUserSettings.WorkOffline = workOfflineNew; EditorApplication.RequestRepaintAllViews(); } EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Content.allowAsyncUpdate, EditorUserSettings.allowAsyncStatusUpdate); } if (Provider.hasCheckoutSupport) { EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Content.showFailedCheckouts, EditorUserSettings.showFailedCheckout); EditorUserSettings.overwriteFailedCheckoutAssets = EditorGUILayout.Toggle(Content.overwriteFailedCheckoutAssets, EditorUserSettings.overwriteFailedCheckoutAssets); } var newOverlayIcons = EditorGUILayout.Toggle(Content.overlayIcons, EditorUserSettings.overlayIcons); if (newOverlayIcons != EditorUserSettings.overlayIcons) { EditorUserSettings.overlayIcons = newOverlayIcons; EditorApplication.RequestRepaintAllViews(); } GUI.enabled = editorEnabled; // Semantic merge popup EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Content.smartMerge, (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList); DrawOverlayDescriptions(); } GUILayout.Space(10); int index = (int)EditorSettings.serializationMode; using (new EditorGUI.DisabledScope(!collabEnabled)) { GUI.enabled = !collabEnabled; GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel); GUI.enabled = editorEnabled && !collabEnabled; CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode); } if (collabEnabled) { EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning); } GUILayout.Space(10); GUI.enabled = true; GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel); GUI.enabled = editorEnabled; index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1); CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode); { var wasEnabled = GUI.enabled; GUI.enabled = true; DoAssetPipelineSettings(); if (m_AssetPipelineMode.intValue == (int)AssetPipelineMode.Version2) DoCacheServerSettings(); GUI.enabled = wasEnabled; } GUILayout.Space(10); GUI.enabled = true; GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel); GUI.enabled = editorEnabled; { EditorGUI.BeginChangeCheck(); SceneAsset scene = EditorSettings.prefabRegularEnvironment; scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false); if (EditorGUI.EndChangeCheck()) EditorSettings.prefabRegularEnvironment = scene; } { EditorGUI.BeginChangeCheck(); SceneAsset scene = EditorSettings.prefabUIEnvironment; scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false); if (EditorGUI.EndChangeCheck()) EditorSettings.prefabUIEnvironment = scene; } GUILayout.Space(10); GUI.enabled = true; GUILayout.Label(Content.graphics, EditorStyles.boldLabel); GUI.enabled = editorEnabled; EditorGUI.BeginChangeCheck(); bool showRes = LightmapVisualization.showResolution; showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes); if (EditorGUI.EndChangeCheck()) LightmapVisualization.showResolution = showRes; GUILayout.Space(10); GUI.enabled = true; GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel); GUI.enabled = editorEnabled; index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1); CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode); if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn || EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly) { index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2); CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower); } DoProjectGenerationSettings(); DoEtcTextureCompressionSettings(); DoLineEndingsSettings(); DoStreamingSettings(); DoShaderCompilationSettings(); DoEnterPlayModeSettings(); serializedObject.ApplyModifiedProperties(); m_EditorUserSettings.ApplyModifiedProperties(); }
private void BuiltinCustomSplashScreenGUI() { EditorGUILayout.LabelField(k_Texts.splashTitle, EditorStyles.boldLabel); using (new EditorGUI.DisabledScope(!licenseAllowsDisabling)) { EditorGUILayout.PropertyField(m_ShowUnitySplashScreen, k_Texts.showSplash); if (!m_ShowUnitySplashScreen.boolValue) { return; } } GUIContent buttonLabel = SplashScreen.isFinished ? k_Texts.previewSplash : k_Texts.cancelPreviewSplash; Rect previewButtonRect = GUILayoutUtility.GetRect(buttonLabel, "button"); previewButtonRect = EditorGUI.PrefixLabel(previewButtonRect, new GUIContent(" ")); if (GUI.Button(previewButtonRect, buttonLabel)) { if (SplashScreen.isFinished) { SplashScreen.Begin(); var gv = GameView.GetMainGameView(); if (gv) { gv.Focus(); } EditorApplication.update += PollSplashState; } else { SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate); EditorApplication.update -= PollSplashState; } GameView.RepaintAll(); } EditorGUILayout.PropertyField(m_SplashScreenLogoStyle, k_Texts.splashStyle); // Animation EditorGUILayout.PropertyField(m_SplashScreenAnimation, k_Texts.animate); m_ShowAnimationControlsAnimator.target = m_SplashScreenAnimation.intValue == (int)PlayerSettings.SplashScreen.AnimationMode.Custom; if (EditorGUILayout.BeginFadeGroup(m_ShowAnimationControlsAnimator.faded)) { EditorGUI.indentLevel++; EditorGUILayout.Slider(m_SplashScreenLogoAnimationZoom, 0.0f, 1.0f, k_Texts.logoZoom); EditorGUILayout.Slider(m_SplashScreenBackgroundAnimationZoom, 0.0f, 1.0f, k_Texts.backgroundZoom); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); // Logos EditorGUILayout.LabelField(k_Texts.logosTitle, EditorStyles.boldLabel); using (new EditorGUI.DisabledScope(!Application.HasProLicense())) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_ShowUnitySplashLogo, k_Texts.showLogo); if (EditorGUI.EndChangeCheck()) { if (!m_ShowUnitySplashLogo.boolValue) { RemoveUnityLogoFromLogosList(); } else if (m_SplashScreenDrawMode.intValue == (int)PlayerSettings.SplashScreen.DrawMode.AllSequential) { AddUnityLogoToLogosList(); } } m_ShowLogoControlsAnimator.target = m_ShowUnitySplashLogo.boolValue; } if (EditorGUILayout.BeginFadeGroup(m_ShowLogoControlsAnimator.faded)) { EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); var oldDrawmode = m_SplashScreenDrawMode.intValue; EditorGUILayout.PropertyField(m_SplashScreenDrawMode, k_Texts.drawMode); if (oldDrawmode != m_SplashScreenDrawMode.intValue) { if (m_SplashScreenDrawMode.intValue == (int)PlayerSettings.SplashScreen.DrawMode.UnityLogoBelow) { RemoveUnityLogoFromLogosList(); } else { AddUnityLogoToLogosList(); } } EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); m_LogoList.DoLayoutList(); EditorGUILayout.Space(); // Background EditorGUILayout.LabelField(k_Texts.backgroundTitle, EditorStyles.boldLabel); EditorGUILayout.Slider(m_SplashScreenOverlayOpacity, Application.HasProLicense() ? k_MinProEditionOverlayOpacity : k_MinPersonalEditionOverlayOpacity, 1.0f, k_Texts.overlayOpacity); m_ShowBackgroundColorAnimator.target = m_SplashScreenBackgroundLandscape.objectReferenceValue == null; if (EditorGUILayout.BeginFadeGroup(m_ShowBackgroundColorAnimator.faded)) { EditorGUILayout.PropertyField(m_SplashScreenBackgroundColor, k_Texts.backgroundColor); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(m_SplashScreenBlurBackground, k_Texts.blurBackground); EditorGUI.BeginChangeCheck(); ObjectReferencePropertyField <Sprite>(m_SplashScreenBackgroundLandscape, k_Texts.backgroundImage); if (EditorGUI.EndChangeCheck() && m_SplashScreenBackgroundLandscape.objectReferenceValue == null) { m_SplashScreenBackgroundPortrait.objectReferenceValue = null; } using (new EditorGUI.DisabledScope(m_SplashScreenBackgroundLandscape.objectReferenceValue == null)) { ObjectReferencePropertyField <Sprite>(m_SplashScreenBackgroundPortrait, k_Texts.backgroundPortraitImage); } }
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 DrawControls() { if ((Object)this.m_Manager == (Object)null) { return; } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_HostMigrationProperty, this.m_HostMigrationLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_ShowGUIProperty); if (this.m_Manager.showGUI) { EditorGUILayout.PropertyField(this.m_OffsetXProperty); EditorGUILayout.PropertyField(this.m_OffsetYProperty); } if (EditorGUI.EndChangeCheck()) { this.serializedObject.ApplyModifiedProperties(); } if (!Application.isPlaying) { return; } EditorGUILayout.Separator(); EditorGUILayout.LabelField("Disconnected From Host", this.m_Manager.disconnectedFromHost.ToString(), new GUILayoutOption[0]); EditorGUILayout.LabelField("Waiting to become New Host", this.m_Manager.waitingToBecomeNewHost.ToString(), new GUILayoutOption[0]); EditorGUILayout.LabelField("Waitingto Reconnect to New Host", this.m_Manager.waitingReconnectToNewHost.ToString(), new GUILayoutOption[0]); EditorGUILayout.LabelField("Your ConnectionId", this.m_Manager.oldServerConnectionId.ToString(), new GUILayoutOption[0]); EditorGUILayout.LabelField("New Host Address", this.m_Manager.newHostAddress, new GUILayoutOption[0]); if (this.m_Manager.peers != null) { this.m_ShowPeers = EditorGUILayout.Foldout(this.m_ShowPeers, "Peers"); if (this.m_ShowPeers) { ++EditorGUI.indentLevel; foreach (PeerInfoMessage peer in this.m_Manager.peers) { EditorGUILayout.LabelField("Peer: ", peer.ToString(), new GUILayoutOption[0]); } --EditorGUI.indentLevel; } } if (this.m_Manager.pendingPlayers == null) { return; } this.m_ShowPlayers = EditorGUILayout.Foldout(this.m_ShowPlayers, "Pending Players"); if (!this.m_ShowPlayers) { return; } ++EditorGUI.indentLevel; using (Dictionary <int, NetworkMigrationManager.ConnectionPendingPlayers> .KeyCollection.Enumerator enumerator1 = this.m_Manager.pendingPlayers.Keys.GetEnumerator()) { while (enumerator1.MoveNext()) { int current1 = enumerator1.Current; EditorGUILayout.LabelField("Connection: ", current1.ToString(), new GUILayoutOption[0]); ++EditorGUI.indentLevel; using (List <NetworkMigrationManager.PendingPlayerInfo> .Enumerator enumerator2 = this.m_Manager.pendingPlayers[current1].players.GetEnumerator()) { while (enumerator2.MoveNext()) { NetworkMigrationManager.PendingPlayerInfo current2 = enumerator2.Current; EditorGUILayout.ObjectField("Player netId:" + (object)current2.netId + " contId:" + (object)current2.playerControllerId, (Object)current2.obj, typeof(GameObject), false, new GUILayoutOption[0]); } } --EditorGUI.indentLevel; } } --EditorGUI.indentLevel; }
public override void OnInspectorGUI() { bool targetChanged = false; if (target != state) { addStatePortionName = ""; targetChanged = true; } state = (State)target; if (targetChanged) { var layer = state.profile.controller.layers[state.profile.controllerLayer]; var animState = Utils.FindState(layer.stateMachine, state.stateName); clip = animState.motion as AnimationClip; var sb = new System.Text.StringBuilder(); var events = AnimationUtility.GetAnimationEvents(clip); sb.AppendFormat("Events ({0}) ", events.Length).AppendLine(); if (events.Length > 0) { foreach (var ev in events) { sb.Append(string.Format("{0,4}", (int)FrameUtil.Time2Frame(ev.time))).Append("F "); sb.Append(ev.functionName); sb.AppendLine(); } } sb.AppendLine(); var bindings = AnimationUtility.GetCurveBindings(clip); sb.AppendFormat("Bindings ({0})", bindings.Length).AppendLine(); foreach (var binding in bindings) { sb.Append(" ").Append(binding.path).Append(binding.path == "" ? "" : "/") .Append("<").Append(binding.type.Name).Append(">.") .Append(binding.propertyName).AppendLine(); } summary = sb.ToString(); } EditorGUI.BeginChangeCheck(); EGL.LabelField("Name", state.stateName); EGL.LabelField("Frames", state.frames.ToString()); bool lastGUIEnabled = GUI.enabled; GUI.enabled = false; EGL.ObjectField("Clip", clip, typeof(AnimationClip), allowSceneObjects: false); GUI.enabled = lastGUIEnabled; if (summary.Length > 0) { EGL.HelpBox(summary, MessageType.None); } state.tags = InspectTags(state.tags); EGL.Space(); using (new EGL.VerticalScope(EditorStyles.helpBox)) { ++EditorGUI.indentLevel; InspectBehaviourList(state.behaviours); --EditorGUI.indentLevel; EGL.Space(); } EGL.LabelField("Portions"); var portions = state.portions; for (int i = 0; i < portions.Count; ++i) { var portion = portions[i]; bool active = activePortions.Contains(portion); active = EGL.Foldout(active, portion.name); if (active) { activePortions.Add(portion); } else { activePortions.Remove(portion); } if (active) { ++EditorGUI.indentLevel; EGL.BeginHorizontal(); portion.name = EGL.TextField("Name", portion.name); // GL.FlexibleSpace(); if (GL.Button("-", GUILayout.Width(30))) { portions.RemoveAt(i); --i; } EGL.EndHorizontal(); portion.range = EditorGUIUtil.FrameRangeSlider("Range", portion.range, state.frames); portion.includeEnd = EGL.Toggle("Include nt>=1", portion.includeEnd); portion.tags = InspectTags(portion.tags); using (new EGL.VerticalScope(EditorStyles.helpBox)) { InspectBehaviourList(portion.behaviours); } --EditorGUI.indentLevel; } } EGL.Space(); EGL.Space(); EGL.BeginHorizontal(); addStatePortionName = EGL.TextField(addStatePortionName); if (GUI.enabled && GL.Button("Add Portion", GL.Width(90))) { var portion = new StatePortion { name = addStatePortionName }; portions.Add(portion); addStatePortionName = ""; } EGL.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(state); } }
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 InspectBehaviourList(List <StateBehaviour> list) { using (new EGL.HorizontalScope()) { EGL.LabelField("Behaviours", EditorStyles.boldLabel); GL.FlexibleSpace(); var listHash = list.GetHashCode(); if (GL.Button("+", GL.Width(30)) && popupRects.ContainsKey(listHash)) { PopupWindow.Show(popupRects[listHash], new AddBehaviourPopup(state.profile, list)); } if (Event.current.type == EventType.Repaint) { popupRects.Remove(listHash); popupRects.Add(listHash, GUILayoutUtility.GetLastRect()); } } for (int i = 0; i < list.Count; ++i) { var behaviour = list[i]; var active = activeBehaviours.Contains(behaviour); if (!behaviour) { list.RemoveAt(i); --i; continue; } EGL.BeginHorizontal(); active = EGL.Foldout(active, behaviour.name); if (GL.Button("-", GL.Width(30))) { DestroyImmediate(behaviour, true); list.RemoveAt(i); --i; } EGL.EndHorizontal(); if (!behaviour) { continue; } if (active) { activeBehaviours.Add(behaviour); } else { activeBehaviours.Remove(behaviour); } if (active) { ++EditorGUI.indentLevel; GetBehaviorEditor(behaviour).OnInspectorGUI(); --EditorGUI.indentLevel; } } if (GUI.enabled) { GL.BeginHorizontal(); GL.FlexibleSpace(); GL.FlexibleSpace(); GL.EndHorizontal(); } }
private void Audio3DGUI() { EditorGUILayout.Slider(m_DopplerLevel, 0.0f, 5.0f, Styles.dopplerLevelLabel); // Spread control AnimProp(Styles.spreadLabel, m_AudioCurves[kSpreadCurveID].curveProp, 0.0f, 360.0f, true); // Rolloff mode if (m_RolloffMode.hasMultipleDifferentValues || (m_RolloffMode.enumValueIndex == (int)AudioRolloffMode.Custom && m_AudioCurves[kRolloffCurveID].curveProp.hasMultipleDifferentValues) ) { EditorGUILayout.TargetChoiceField(m_AudioCurves[kRolloffCurveID].curveProp, Styles.rolloffLabel, SetRolloffToTarget); } else { EditorGUILayout.PropertyField(m_RolloffMode, Styles.rolloffLabel); if ((AudioRolloffMode)m_RolloffMode.enumValueIndex != AudioRolloffMode.Custom) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_MinDistance); if (EditorGUI.EndChangeCheck()) { m_MinDistance.floatValue = Mathf.Clamp(m_MinDistance.floatValue, 0, m_MaxDistance.floatValue / 1.01f); } } else { using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.LabelField(m_MinDistance.displayName, Styles.controlledByCurveLabel); } } } // Max distance control EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_MaxDistance); if (EditorGUI.EndChangeCheck()) { m_MaxDistance.floatValue = Mathf.Min(Mathf.Max(Mathf.Max(m_MaxDistance.floatValue, 0.01f), m_MinDistance.floatValue * 1.01f), 1000000.0f); } Rect r = GUILayoutUtility.GetAspectRect(1.333f, GUI.skin.textField); r.xMin += EditorGUI.indent; if (Event.current.type != EventType.Layout && Event.current.type != EventType.Used) { m_CurveEditor.rect = new Rect(r.x, r.y, r.width, r.height); } // Draw Curve Editor UpdateWrappersAndLegend(); GUI.Label(m_CurveEditor.drawRect, GUIContent.none, "TextField"); m_CurveEditor.hRangeLocked = Event.current.shift; m_CurveEditor.vRangeLocked = EditorGUI.actionKey; m_CurveEditor.OnGUI(); // Draw current listener position if (targets.Length == 1) { AudioSource t = (AudioSource)target; AudioListener audioListener = (AudioListener)FindObjectOfType(typeof(AudioListener)); if (audioListener != null) { float distToListener = (AudioUtil.GetListenerPos() - t.transform.position).magnitude; DrawLabel("Listener", distToListener, r); } } // Draw legend DrawLegend(); if (!m_CurveEditor.InLiveEdit()) { // Check if any of the curves changed foreach (AudioCurveWrapper audioCurve in m_AudioCurves) { if ((m_CurveEditor.GetCurveWrapperFromID(audioCurve.id) != null) && (m_CurveEditor.GetCurveWrapperFromID(audioCurve.id).changed)) { AnimationCurve changedCurve = m_CurveEditor.GetCurveWrapperFromID(audioCurve.id).curve; // Never save a curve with no keys if (changedCurve.length > 0) { audioCurve.curveProp.animationCurveValue = changedCurve; m_CurveEditor.GetCurveWrapperFromID(audioCurve.id).changed = false; // Volume curve special handling if (audioCurve.type == AudioCurveType.Volume) { m_RolloffMode.enumValueIndex = (int)AudioRolloffMode.Custom; } } } } } }