void DrawAfterDialogPanel() { _afterScrollPos = EditorGUILayout.BeginScrollView(_afterScrollPos); _curDialogAsset.TalkEndEventType = (E_TalkEndEventType)EditorGUILayout.EnumPopup("结束事件类型", _curDialogAsset.TalkEndEventType); switch (_curDialogAsset.TalkEndEventType) { case E_TalkEndEventType.Transition: _curDialogAsset.MaskType = (E_MaskType)EditorGUILayout.EnumPopup("过渡类型", _curDialogAsset.MaskType); _curDialogAsset.LinkedDialogAsset = (DialogAsset)EditorGUILayout.ObjectField("连接对话", _curDialogAsset.LinkedDialogAsset, typeof(DialogAsset), false); break; case E_TalkEndEventType.Night: _curDialogAsset.LinkedDialogAsset = (DialogAsset)EditorGUILayout.ObjectField("连接对话", _curDialogAsset.LinkedDialogAsset, typeof(DialogAsset), false); GUILayout.Label("记事本当晚新记录的内容"); _recordDataList?.DoLayoutList(); break; case E_TalkEndEventType.Select: _talkEndEventList.DoLayoutList(); break; case E_TalkEndEventType.GameOver: break; } EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { serializedObject.Update(); _list.DoLayoutList(); _innerList?.DoLayoutList(); serializedObject.ApplyModifiedProperties(); }
private void OnGuiSettingsAccount() { var style = new GUIStyle { padding = new RectOffset(5, 5, 5, 5) }; EditorGUILayout.BeginVertical(style); // TODO:: accounts if (_reorderableList == null) { _reorderableList = new ReorderableList(_accounts, typeof(OpenLoaderAccount)) { drawHeaderCallback = DrawHeader, elementHeightCallback = ElementHeight, drawElementCallback = DrawElement, drawElementBackgroundCallback = DrawElementBackground, onAddCallback = OnAdd, onRemoveCallback = OnRemove }; } _reorderableList?.DoLayoutList(); EditorGUILayout.EndVertical(); }
public override void Draw() { using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Import", GUILayout.Width(140), GUILayout.Height(28))) { MDEditorBase.UseCase.ImportTable <Item>( // 1 (builder, list) => { var excepts = GameDatabase.DB.ItemTable.All.Select(x => x.id).ToArray(); // 2 excepts = excepts.Except(list.Select(x => x.id).ToArray()).ToArray(); // 無いIdのものを削除 builder.RemoveItem(excepts); // 3 // データ差し替え builder.ReplaceAll(list.ToArray()); }, () => { current = null; CreateItemList(); }); } if (GUILayout.Button("Export", GUILayout.Width(140), GUILayout.Height(28))) { MDEditorBase.UseCase.ExportTable(GameDatabase.DB.ItemTable.All.ToList()); // 4 } } using (new GUILayout.HorizontalScope()) { // 左側 using (new GUILayout.VerticalScope(GUILayout.Width(160))) { cardLeftScrollPos = EditorGUILayout.BeginScrollView(cardLeftScrollPos, GUI.skin.box); if (itemList == null) { CreateItemList(); } itemList?.DoLayoutList(); EditorGUILayout.EndScrollView(); } if (current != null) { // 真ん中 using (new GUILayout.VerticalScope()) { cardCenterScrollPos = EditorGUILayout.BeginScrollView(cardCenterScrollPos, GUI.skin.box); using (new GUILayout.VerticalScope()) { current?.Draw(); } GUILayout.Space(10); EditorGUILayout.EndScrollView(); } } } }
public static SettingsProvider CreateLuaCheckSettingProvider() { var provider = new SettingsProvider("Project/Lua Debug", SettingsScope.Project) { label = "Setup Lua Debug", guiHandler = search => { EditorGUI.indentLevel = 1; var settings = LuaDebugSetting.GetSerializedSettings(); var debuggerConnectionModeProp = settings.FindProperty("m_debugMode"); EditorGUILayout.PropertyField(debuggerConnectionModeProp); var mode = (LuaDebugSetting.DebugMode)debuggerConnectionModeProp.intValue; var debugPortProp = settings.FindProperty("m_debugPort"); switch (mode) { case LuaDebugSetting.DebugMode.None: break; case LuaDebugSetting.DebugMode.ConnectIDE: EditorGUILayout.PropertyField(debugPortProp, m_connectPortText); break; case LuaDebugSetting.DebugMode.ListenAndWait: EditorGUILayout.PropertyField(debugPortProp, m_listenPortText); break; case LuaDebugSetting.DebugMode.CoverageMode: var coverageCheckFilesProp = settings.FindProperty("m_coverageCheckFiles"); EditorGUILayout.PropertyField(coverageCheckFilesProp); break; default: throw new ArgumentOutOfRangeException(); } if (mode != LuaDebugSetting.DebugMode.None) { var emmyCoreLuaSearchPathProp = settings.FindProperty("m_emmyCoreLuaSearchPath"); EditorGUILayout.PropertyField(emmyCoreLuaSearchPathProp); } if (debugPortProp.intValue < 10000) { debugPortProp.intValue = 10000; } var enabledProp = settings.FindProperty("m_mvvmBreakEnabled"); EditorGUILayout.PropertyField(enabledProp); if (Application.isPlaying) { m_mvvmWatchGUI?.DoLayoutList(); } settings.ApplyModifiedProperties(); } }; return(provider); }
public override void OnInspectorGUI() { library = EditorGUILayout.ObjectField("Library", library, typeof(SpiritLibrary), false) as SpiritLibrary; atkLibrary = EditorGUILayout.ObjectField("AttackLibrary", atkLibrary, typeof(AttackLibrary), false) as AttackLibrary; serializedObject.Update(); if (library != null && atkLibrary != null) { RenderGeneratorStuff(); } spiritList.DoLayoutList(); if (selectedSpirit != null) { RenderSpirit(selectedSpirit); attackList?.DoLayoutList(); if (selectedAttack != null) { RenderAttack(selectedAttack); } } serializedObject.ApplyModifiedProperties(); }
public void Update() { _serializedObject.Update(); _list?.DoLayoutList(); _serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); _objectsInfo?.DoLayoutList(); serializedObject.ApplyModifiedProperties(); if (GUILayout.Button("Save changes")) { EnumGenerator.GenerateEnumFromStringList("PoolObjectTypes", "ObjectType", ((ObjectsConfig)target).ObjectsList.Select(obj => obj.Name) .Where(objName => _provider.IsValidIdentifier(objName))); } }
private void DrawRecipeDataFields() { //Crafting result + amount selectedRecipe.result.item = (ScriptableItemData)EditorGUILayout.ObjectField("Result", selectedRecipe.result.item ?? null, typeof(ScriptableItemData), false, GUILayout.Width(recipeDataDisplay.width * 0.5f)); selectedRecipe.result.amount = EditorGUI.IntField(new Rect(recipeDataDisplay.width * 0.52f, recipeDataDisplay.y - 5, recipeDataDisplay.width * 0.25f, EditorGUIUtility.singleLineHeight), "Amount", selectedRecipe.result != null ? selectedRecipe.result.amount : 0); //Crafting Time selectedRecipe.craftingTime = EditorGUI.FloatField(new Rect(0, recipeDataDisplay.y + EditorGUIUtility.singleLineHeight, recipeDataDisplay.width * 0.45f, EditorGUIUtility.singleLineHeight), "Crafting Time", selectedRecipe.craftingTime); GUILayout.Space(20); requiredItems?.DoLayoutList(); }
private void OnMiniMapGUI() { var curName = SceneManager.GetActiveScene().name; if (sceneName != curName) { ClearAll(); sceneName = curName; } var filePath = $"Assets/{miniMapGenerateDirPath.GetAfterSubstring($"{Application.dataPath}/")}/Map_{sceneName}.asset"; EditorGUILayout.LabelField("生成路径", filePath); emptyColor = EditorGUILayout.ColorField("空白区域颜色", emptyColor); tileMapInfoList?.DoLayoutList(); if (GUILayout.Button("加载场景所有TileMap", GUILayout.Height(2 * EditorGUIUtility.singleLineHeight))) { LoadTileMapsFromScene(); } EditorGUILayout.BeginHorizontal(GUILayout.Height(2 * EditorGUIUtility.singleLineHeight)); if (GUILayout.Button("清空所有", GUILayout.Height(2 * EditorGUIUtility.singleLineHeight))) { ClearAll(); } if (GUILayout.Button("启用所有", GUILayout.Height(2 * EditorGUIUtility.singleLineHeight))) { foreach (var info in tileMapInfos) { info.enable = true; } } if (GUILayout.Button("禁用所有", GUILayout.Height(2 * EditorGUIUtility.singleLineHeight))) { foreach (var info in tileMapInfos) { info.enable = false; } } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("生成地图", GUILayout.Height(2 * EditorGUIUtility.singleLineHeight))) { GenerateMap(); } }
protected override void OnInspectorGUI() { EditorGUILayout.PropertyField(makingMethod); EditorGUILayout.PropertyField(canMakeByTry); EditorGUILayout.PropertyField(formulation); if (yields.isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(yields.isExpanded, "产量表")) { if (yields.isExpanded) { list?.DoLayoutList(); } } EditorGUILayout.EndFoldoutHeaderGroup(); }
public static void Draw(Group group) { GUILayout.Space(3); GUILayout.BeginHorizontal(); GUILayout.Space(-6); GUILayout.BeginVertical(); _statesList?.DoLayoutList(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); DrawAddButton(group); }
protected override void DisplaySerializedDataPropertyField() { EditorGUILayout.HelpBox(CapacityStatusString, MessageType.None); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_SerializedDataList.serializedProperty.FindPropertyRelative("Array.size")); // align control fields with those outside the reorderable list control var labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth -= 19f; m_SerializedDataList?.DoLayoutList(); EditorGUIUtility.labelWidth = labelWidth; if (EditorGUI.EndChangeCheck()) { RebuildBufferStatusString(); } }
private void DrawRecipeListDisplay() { recipeListDisplay = new Rect(5, 5, position.width * 0.30f, position.height); GUILayout.BeginArea(recipeListDisplay); //Input field for a list of recipes selectedCraftingList = (CraftingList)EditorGUILayout.ObjectField(selectedCraftingList, typeof(CraftingList), false); if (selectedCraftingList != null) { //TODO: find a way to live update this list if (GUILayout.Button("UpdateList")) { DrawRecipesList(); } recipeList?.DoLayoutList(); } GUILayout.EndArea(); }
private static void OnPreferencesGUI() { scroll = EditorGUILayout.BeginScrollView(scroll, false, false); EditorGUILayout.Separator(); Enabled.DoGUI(); EditorGUILayout.Separator(); EditorGUILayout.HelpBox("Each item has a tooltip explaining what it does, keep the mouse over it to see.", MessageType.Info); EditorGUILayout.Separator(); using (Enabled.GetEnabledScope()) { using (new GUIIndent("Misc settings")) { using (new GUIIndent("Margins")) { RightMargin.DoGUISlider(-50, 50); LeftMargin.DoGUISlider(-50, 50); Indent.DoGUISlider(0, 35); } TreeOpacity.DoGUISlider(0f, 1f); using (new GUIIndent()) using (SelectOnTree.GetFadeScope(TreeOpacity.Value > 0.01f)) SelectOnTree.DoGUI(); Tooltips.DoGUI(); using (new GUIIndent()) using (RelevantTooltipsOnly.GetFadeScope(Tooltips)) RelevantTooltipsOnly.DoGUI(); EnhancedSelection.DoGUI(); Trailing.DoGUI(); ChangeAllSelected.DoGUI(); NumericChildExpand.DoGUI(); using (HideDefaultIcon.GetFadeScope(IsButtonEnabled(new Icons.GameObjectIcon()))) HideDefaultIcon.DoGUI(); GUI.changed = false; using (AllowSelectingLocked.GetFadeScope(IsButtonEnabled(new Icons.Lock()))) AllowSelectingLocked.DoGUI(); using (AllowSelectingLockedSceneView.GetFadeScope(IsButtonEnabled(new Icons.Lock()) && AllowSelectingLocked)) AllowSelectingLockedSceneView.DoGUI(); if (GUI.changed && EditorUtility.DisplayDialog("Relock all objects", "Would you like to relock all objects?\n" + "This is recommended when changing this setting and might take a few seconds on large scenes" + "\nIt's also recommended to do this on all scenes", "Yes", "No")) { Utility.RelockAllObjects(); } HoverTintColor.DoGUI(); } using (new GUIIndent("Row separators")) { LineSize.DoGUISlider(0, 6); using (LineColor.GetFadeScope(LineSize > 0)) LineColor.DoGUI(); OddRowColor.DoGUI(); EvenRowColor.DoGUI(); GUI.changed = false; var rect = EditorGUILayout.GetControlRect(false, rowColorsList.GetHeight()); rect.xMin += EditorGUI.indentLevel * 16f; rowColorsList.DoList(rect); } MiniLabel.DoGUI(); using (new GUIIndent()) { using (SmallerMiniLabel.GetFadeScope(MiniLabel.Value != MiniLabelType.None)) SmallerMiniLabel.DoGUI(); using (HideDefaultTag.GetFadeScope(MiniLabelTagEnabled)) HideDefaultTag.DoGUI(); using (HideDefaultLayer.GetFadeScope(MiniLabelLayerEnabled)) HideDefaultLayer.DoGUI(); using (CentralizeMiniLabelWhenPossible.GetFadeScope((HideDefaultLayer || HideDefaultTag) && (MiniLabel.Value == MiniLabelType.TagAndLayer || MiniLabel.Value == MiniLabelType.LayerAndTag))) CentralizeMiniLabelWhenPossible.DoGUI(); } LeftSideButtonPref.DoGUI(); using (new GUIIndent()) using (LeftmostButton.GetFadeScope(LeftSideButton != IconBase.rightNone)) LeftmostButton.DoGUI(); using (new GUIIndent("Children behaviour on change")) { using (LockAskMode.GetFadeScope(IsButtonEnabled(new Icons.Lock()))) LockAskMode.DoGUI(); using (LayerAskMode.GetFadeScope(IsButtonEnabled(new Icons.Layer()) || MiniLabelLayerEnabled)) LayerAskMode.DoGUI(); using (TagAskMode.GetFadeScope(IsButtonEnabled(new Icons.Tag()) || MiniLabelTagEnabled)) TagAskMode.DoGUI(); using (StaticAskMode.GetFadeScope(IsButtonEnabled(new Icons.Static()))) StaticAskMode.DoGUI(); using (IconAskMode.GetFadeScope(IsButtonEnabled(new Icons.GameObjectIcon()))) IconAskMode.DoGUI(); EditorGUILayout.HelpBox(string.Format("Pressing down {0} while clicking on a button will make it temporary have the opposite children change mode", Utility.CtrlKey), MessageType.Info); } leftIconsList.displayAdd = LeftIconsMenu.GetItemCount() > 0; leftIconsList.DoLayoutList(); rightIconsList.displayAdd = RightIconsMenu.GetItemCount() > 0; rightIconsList.DoLayoutList(); EditorGUILayout.HelpBox("Alt + Click on child expand toggle makes it expand all the grandchildren too", MessageType.Info); if (IsButtonEnabled(new Icons.Memory())) { EditorGUILayout.HelpBox("\"Memory Used\" may create garbage and consequently framerate stutterings, leave it disabled if maximum performance is important for your project", MessageType.Warning); } if (IsButtonEnabled(new Icons.Lock())) { EditorGUILayout.HelpBox("Remember to always unlock your game objects when removing or disabling this extension, as you won't be able to unlock without it and may lose scene data", MessageType.Warning); } GUI.enabled = true; EditorGUILayout.EndScrollView(); using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(versionContent, GUILayout.Width(170f)); } using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(resetSettingsContent, GUILayout.Width(120f))) { onResetPreferences(); } if (GUILayout.Button(unlockAllContent, GUILayout.Width(120f))) { Utility.UnlockAllObjects(); } if (GUILayout.Button(mailDeveloperContent, GUILayout.Width(120f))) { Application.OpenURL(GetEmailURL()); } } EditorGUILayout.Separator(); Styles.ReloadTooltips(); EditorApplication.RepaintHierarchyWindow(); } }
public override void OnInspectorGUI() { Init(); CheckNullProperties(); if (!networkingManager.isServer && !networkingManager.isClient) { serializedObject.Update(); EditorGUILayout.PropertyField(DontDestroyOnLoadProperty); EditorGUILayout.PropertyField(RunInBackgroundProperty); EditorGUILayout.PropertyField(LogLevelProperty); if (networkingManager.NetworkConfig.HandleObjectSpawning) { EditorGUILayout.Space(); networkPrefabsList.DoLayoutList(); } EditorGUILayout.Space(); channelsList.DoLayoutList(); EditorGUILayout.Space(); if (networkingManager.NetworkConfig.EnableSceneSwitching) { registeredScenesList.DoLayoutList(); EditorGUILayout.Space(); } serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); } else { string instanceType = ""; if (networkingManager.isHost) { instanceType = "Host"; } else if (networkingManager.isServer) { instanceType = "Server"; } else if (networkingManager.isClient) { instanceType = "Client"; } EditorGUILayout.HelpBox("You cannot edit the NetworkConfig when a " + instanceType + " is running", UnityEditor.MessageType.Info); if (GUILayout.Toggle(false, "Stop " + instanceType, EditorStyles.miniButtonMid)) { if (networkingManager.isHost) { networkingManager.StopHost(); } else if (networkingManager.isServer) { networkingManager.StopServer(); } else if (networkingManager.isClient) { networkingManager.StopClient(); } } } //Repaint(); }
public override void OnInspectorGUI() { m_statesList.DoLayoutList(); m_switcherActionList?.DoLayoutList(); serializedObject.ApplyModifiedProperties(); }
void OnGUI() { EditorGUILayout.BeginHorizontal(); TCP2_GUI.HeaderBig(editMode ? "TCP 2 - RAMP EDITOR" : "TCP 2 - RAMP GENERATOR"); TCP2_GUI.HelpButton("Ramp Generator"); EditorGUILayout.EndHorizontal(); TCP2_GUI.Separator(); serializedObject.Update(); if (editMode) { if (!isNewTexture) { var msg = "This will affect <b>all materials</b> that use this texture!" + (editModeFromMaterial ? "\n\nSave as a new texture first if you want to affect this material only." : "\n\nSave as a new texture if you want to keep the original ramp."); EditorGUILayout.LabelField(GUIContent.none, new GUIContent(msg, TCP2_GUI.GetHelpBoxIcon(MessageType.Warning)), TCP2_GUI.HelpBoxRichTextStyle); } var rect = EditorGUILayout.GetControlRect(GUILayout.Height(16f)); var lw = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 50f; var enabled = GUI.enabled; GUI.enabled = false; EditorGUI.ObjectField(rect, "Editing: ", linkedTexture, typeof(Texture2D), false); EditorGUIUtility.labelWidth = lw; GUI.enabled = enabled; } else { /* * EditorGUILayout.BeginHorizontal(); * if (GUILayout.Toggle(tabIndex == 0, "1D RAMP", TCP2_GUI.Tab)) * tabIndex = 0; * if (GUILayout.Toggle(tabIndex == 1, "2D RAMP", TCP2_GUI.Tab)) * tabIndex = 1; * GUILayout.FlexibleSpace(); * EditorGUILayout.EndHorizontal(); * TCP2_GUI.SeparatorSimple(); */ } if (isRamp1d) { GUILayout.Label("Click on the gradient to edit it:"); EditorGUILayout.PropertyField(gradientProperty, GUIContent.none); } else { scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); gradients2dList.DoLayoutList(); EditorGUILayout.EndScrollView(); } if (!editMode) { if (isRamp1d) { textureWidth = EditorGUILayout.IntField("TEXTURE SIZE:", textureWidth); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("64", EditorStyles.miniButtonLeft)) { textureWidth = 64; } if (GUILayout.Button("128", EditorStyles.miniButtonMid)) { textureWidth = 128; } if (GUILayout.Button("256", EditorStyles.miniButtonMid)) { textureWidth = 256; } if (GUILayout.Button("512", EditorStyles.miniButtonMid)) { textureWidth = 512; } if (GUILayout.Button("1024", EditorStyles.miniButtonRight)) { textureWidth = 1024; } EditorGUILayout.EndHorizontal(); } else if (isRamp2d) { GUILayout.BeginHorizontal(); textureWidth = EditorGUILayout.IntField("TEXTURE SIZE:", textureWidth); GUILayout.Label("x"); textureHeight = EditorGUILayout.IntField(GUIContent.none, textureHeight); GUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("64", EditorStyles.miniButtonLeft)) { textureWidth = 64; } if (GUILayout.Button("128", EditorStyles.miniButtonMid)) { textureWidth = 128; } if (GUILayout.Button("256", EditorStyles.miniButtonMid)) { textureWidth = 256; } if (GUILayout.Button("512", EditorStyles.miniButtonMid)) { textureWidth = 512; } if (GUILayout.Button("1024", EditorStyles.miniButtonRight)) { textureWidth = 1024; } GUILayout.Space(8); if (GUILayout.Button("64", EditorStyles.miniButtonLeft)) { textureHeight = 64; } if (GUILayout.Button("128", EditorStyles.miniButtonMid)) { textureHeight = 128; } if (GUILayout.Button("256", EditorStyles.miniButtonMid)) { textureHeight = 256; } if (GUILayout.Button("512", EditorStyles.miniButtonMid)) { textureHeight = 512; } if (GUILayout.Button("1024", EditorStyles.miniButtonRight)) { textureHeight = 1024; } EditorGUILayout.EndHorizontal(); } } if (GUI.changed) { serializedObject.ApplyModifiedProperties(); mGradient.alphaKeys = new[] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) }; if (editMode) { textureIsDirty = true; //Update linked texture if (editedTextureIs2d) { TCP2_GradientManager.SetPixelsFromGradients(linkedTexture, m2dGradients, linkedTexture.width, linkedTexture.height); } else { var pixels = TCP2_GradientManager.GetPixelsFromGradient(mGradient, linkedTexture.width, linkedTexture.height); linkedTexture.SetPixels(pixels); linkedTexture.Apply(true, false); } } } GUILayout.Space(8f); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (editMode) { if (GUILayout.Button("Discard", GUILayout.Width(90f), GUILayout.Height(20f))) { DiscardEditedTexture(); if (editModeFromMaterial) { Close(); } else { OpenTool(); } } if (GUILayout.Button("Apply", GUILayout.Width(90f), GUILayout.Height(20f))) { SaveEditedTexture(); if (editModeFromMaterial) { Close(); } else { OpenTool(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); } var saveButton = false; EditorGUI.BeginDisabledGroup(isRamp2d && (m2dGradients == null || m2dGradients.Length < 2)); if (editMode) { saveButton = GUILayout.Button("Save as...", EditorStyles.miniButton, GUILayout.Width(120f), GUILayout.Height(16f)); } else { saveButton = GUILayout.Button("GENERATE", GUILayout.Width(120f), GUILayout.Height(34f)); } EditorGUI.EndDisabledGroup(); if (saveButton) { var path = EditorUtility.SaveFilePanel("Save Generated Ramp", TCP2_GradientManager.LAST_SAVE_PATH, editMode ? linkedTexture.name : "TCP2_CustomRamp", "png"); if (!string.IsNullOrEmpty(path)) { TCP2_GradientManager.LAST_SAVE_PATH = Path.GetDirectoryName(path); var projectPath = path.Replace(Application.dataPath, "Assets"); GenerateAndSaveTexture(projectPath, isRamp2d); if (editMode) { var newTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(projectPath); if (newTexture != null) { foreach (var mat in linkedMaterials) { mat.SetTexture("_Ramp", newTexture); EditorUtility.SetDirty(mat); } } //Reinitialize edit mode InitEditMode(newTexture, linkedMaterials); } } } EditorGUILayout.EndHorizontal(); if (!editMode) { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Load Texture", EditorStyles.miniButton, GUILayout.Width(120f))) { LoadTexture(); } EditorGUILayout.EndHorizontal(); } }
public override void OnInspectorGUI() { serializedObject.Update(); if (m_prevTileset != m_brush.Tileset) { OnDisable(); OnEnable(); } m_prevTileset = m_brush.Tileset; base.OnInspectorGUI(); if (!m_brush.Tileset) { return; } Vector2 visualTileSize = m_brush.Tileset.VisualTileSize; EditorGUILayout.PropertyField(serializedObject.FindProperty("AnimFPS")); TileSelection tileSelection = ((TilesetBrush)target).Tileset.TileSelection; if (tileSelection != null) { if (GUILayout.Button("Add tile selection as animation frames")) { ((AnimBrush)target).AnimFrames.AddRange(tileSelection.selectionData.Select(x => new AnimBrush.TileAnimFrame() { tileId = x })); } } EditorGUILayout.Space(); // Draw animation GUILayoutUtility.GetRect(1f, 1f, GUILayout.Width(visualTileSize.x), GUILayout.Height(visualTileSize.y)); Rect rAnimFrame = GUILayoutUtility.GetLastRect(); uint tileData = m_brush.GetAnimTileData(); rAnimFrame.center = new Vector2(EditorGUIUtility.currentViewWidth / 2, rAnimFrame.center.y); GUI.Box(new Rect(rAnimFrame.position - Vector2.one, rAnimFrame.size + 2 * Vector2.one), ""); TilesetEditor.DoGUIDrawTileFromTileData(rAnimFrame, tileData, m_brush.Tileset, m_brush.GetAnimUV()); EditorGUILayout.Space(); uint brushTileData = m_frameList.index >= 0 ? m_brush.AnimFrames[m_frameList.index].tileId : Tileset.k_TileData_Empty; brushTileData = BrushTileGridControl.DoTileDataPropertiesLayout(brushTileData, m_brush.Tileset, false); if (m_frameList.index >= 0) { m_brush.AnimFrames[m_frameList.index].tileId = brushTileData; } EditorGUILayout.Space(); // Draw Frames List m_frameList.elementHeight = visualTileSize.y + 10f; m_frameList.DoLayoutList(); EditorGUILayout.HelpBox("Select a frame from list and then select a tile from tile selection window.", MessageType.Info); EditorGUILayout.HelpBox("Add and Remove tiles with '+' and '-' buttons.", MessageType.Info); Repaint(); serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(target); } }
private void OnGUI() { scrollPos = GUILayout.BeginScrollView(scrollPos); int funcBef = funcIndex; funcIndex = GUILayout.Toolbar(funcIndex, new string[] { "字体替换", "组件替换" }); if (funcBef != funcIndex) { textList = null; texts.Clear(); textsPaged.Clear(); textMeshs.Clear(); textMeshsPaged.Clear(); page = 1; maxPage = 1; } onlyOpenScene = EditorGUILayout.Toggle("仅打开的场景", onlyOpenScene); if (!onlyOpenScene) { path = EditorGUILayout.TextField("预制件路径", path); } switch (funcIndex) { case 0: type = (ConvertType)EditorGUILayout.EnumPopup("替换对象", type); switch (type) { case ConvertType.Legacy: textList = new ReorderableList(textsPaged, typeof(Text), true, true, false, false) { drawElementCallback = (rect, index, isActive, isFocused) => { EditorGUI.ObjectField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), textsPaged[index], typeof(Text), false); string path = textsPaged[index].gameObject.GetPath(); EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, rect.width, EditorGUIUtility.singleLineHeight), new GUIContent(path, path)); }, elementHeightCallback = (index) => { return(EditorGUIUtility.singleLineHeight * 2); }, drawNoneElementCallback = (rect) => { EditorGUI.LabelField(rect, "暂无"); }, drawHeaderCallback = (rect) => { EditorGUI.LabelField(rect, "收集到的Text"); GUIStyle style = new GUIStyle() { alignment = TextAnchor.MiddleRight }; style.normal.textColor = GUI.contentColor; EditorGUI.LabelField(new Rect(rect.x + rect.width - 150, rect.y, 30, rect.height), $"{page}/{maxPage}", style); if (GUI.Button(new Rect(rect.x + rect.width - 120, rect.y, 60, rect.height), "上一页")) { if (page > 1) { page--; Refresh(); } } if (GUI.Button(new Rect(rect.x + rect.width - 60, rect.y, 60, rect.height), "下一页")) { if (page * pageEach <= texts.Count) { page++; Refresh(); } } }, }; font = EditorGUILayout.ObjectField("字体", font, typeof(Font), false) as Font; maxPage = Mathf.CeilToInt(texts.Count * 1.0f / pageEach); break; case ConvertType.TMP: textList = new ReorderableList(textMeshsPaged, typeof(TextMeshProUGUI), true, true, false, false) { drawElementCallback = (rect, index, isActive, isFocused) => { EditorGUI.ObjectField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), textMeshsPaged[index], typeof(TextMeshProUGUI), false); string path = textMeshsPaged[index].gameObject.GetPath(); EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, rect.width, EditorGUIUtility.singleLineHeight), new GUIContent(path, path)); }, elementHeightCallback = (index) => { return(EditorGUIUtility.singleLineHeight * 2); }, drawNoneElementCallback = (rect) => { EditorGUI.LabelField(rect, "暂无"); }, drawHeaderCallback = (rect) => { EditorGUI.LabelField(rect, "收集到的TMP"); GUIStyle style = new GUIStyle() { alignment = TextAnchor.MiddleRight }; style.normal.textColor = GUI.contentColor; EditorGUI.LabelField(new Rect(rect.x + rect.width - 150, rect.y, 30, rect.height), $"{page}/{maxPage}", style); if (GUI.Button(new Rect(rect.x + rect.width - 120, rect.y, 60, rect.height), "上一页")) { if (page > 1) { page--; Refresh(); } } if (GUI.Button(new Rect(rect.x + rect.width - 60, rect.y, 60, rect.height), "下一页")) { if (page * pageEach <= textMeshs.Count) { page++; Refresh(); } } }, }; fontAsset = EditorGUILayout.ObjectField("字体资源", fontAsset, typeof(TMP_FontAsset), false) as TMP_FontAsset; maxPage = Mathf.CeilToInt(textMeshs.Count * 1.0f / pageEach); break; default: break; } if (GUILayout.Button("一键收集")) { Stopwatch sw = new Stopwatch(); sw.Start(); switch (type) { case ConvertType.Legacy: texts.Clear(); if (onlyOpenScene && ZetanUtility.ActiveScene == null) { Debug.LogWarning("没有打开的场景"); } else if (ZetanUtility.ActiveScene != null) { foreach (var root in ZetanUtility.ActiveScene.GetRootGameObjects()) { foreach (var text in root.GetComponentsInChildren <Text>()) { texts.Add(text); } } } if (!onlyOpenScene) { foreach (var go in ZetanUtility.Editor.LoadAssets <GameObject>(path)) { foreach (var text in go.GetComponentsInChildren <Text>()) { texts.Add(text); } } } break; case ConvertType.TMP: textMeshs.Clear(); if (onlyOpenScene && ZetanUtility.ActiveScene == null) { Debug.LogWarning("没有打开的场景"); } else if (ZetanUtility.ActiveScene != null) { foreach (var root in ZetanUtility.ActiveScene.GetRootGameObjects()) { foreach (var text in root.GetComponentsInChildren <TextMeshProUGUI>()) { textMeshs.Add(text); } } } if (!onlyOpenScene) { foreach (var go in ZetanUtility.Editor.LoadAssets <GameObject>(path)) { foreach (var text in go.GetComponentsInChildren <TextMeshProUGUI>()) { textMeshs.Add(text); } } } break; default: break; } Refresh(); Debug.Log($"收集完成,耗时 {sw.ElapsedMilliseconds} ms"); } if (GUILayout.Button("一键替换")) { Replace(); } break; case 1: type = (ConvertType)EditorGUILayout.EnumPopup("替换对象", type); EditorGUILayout.HelpBox("敬请期待", MessageType.Info); break; default: break; } textList?.DoLayoutList(); GUILayout.EndScrollView(); }
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(); PlayModeView.RepaintAll(); var playModeView = PlayModeView.GetMainPlayModeView(); if (playModeView) { playModeView.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.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(); } } } 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); } }
void DrawDialogueView(DialogueAsset asset) { EditorGUILayout.BeginHorizontal(); EditorGUIUtility.labelWidth = 60; asset.DialogType = (E_DialogType)EditorGUILayout.EnumPopup("对话框类型", asset.DialogType); if (asset.DialogType == E_DialogType.FullScreen) { EditorGUIUtility.labelWidth = 90; asset.IsNewTalk = EditorGUILayout.Toggle("是否为新段落", asset.IsNewTalk); asset.IsNewPage = EditorGUILayout.Toggle("是否为新的一页", asset.IsNewPage); } else { asset.TalkType = (E_TalkType)EditorGUILayout.EnumPopup("内容类型", asset.TalkType); } asset.MaskType = (E_MaskType)EditorGUILayout.EnumPopup("显示动画", asset.MaskType); GUILayout.Label("背景"); asset.Background = (GameObject)EditorGUILayout.ObjectField(asset.Background, typeof(GameObject), false); asset.Bgm = (AudioClip)EditorGUILayout.ObjectField("背景音乐", asset.Bgm, typeof(AudioClip), false); EditorGUILayout.EndHorizontal(); if (asset.DialogType == E_DialogType.Normal) { EditorGUIUtility.labelWidth = 60; EditorGUILayout.BeginHorizontal(); asset.LeftBody = (GameObject)EditorGUILayout.ObjectField("立绘(左)", asset.LeftBody, typeof(GameObject), false); asset.LeftBodyShowType = (E_BodyShowType)EditorGUILayout.EnumPopup("显示类型", asset.LeftBodyShowType); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); asset.RightBody = (GameObject)EditorGUILayout.ObjectField("立绘(右)", asset.RightBody, typeof(GameObject), false); asset.RightBodyShowType = (E_BodyShowType)EditorGUILayout.EnumPopup("显示类型", asset.RightBodyShowType); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); asset.CenterBody = (GameObject)EditorGUILayout.ObjectField("立绘(中)", asset.CenterBody, typeof(GameObject), false); asset.CenterBodyShowType = (E_BodyShowType)EditorGUILayout.EnumPopup("显示类型", asset.CenterBodyShowType); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); asset.BottomBody = (GameObject)EditorGUILayout.ObjectField("立绘(下)", asset.BottomBody, typeof(GameObject), false); asset.BottomBodyShowType = (E_BodyShowType)EditorGUILayout.EnumPopup("显示类型", asset.BottomBodyShowType); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUIUtility.labelWidth = 60; asset.NamePos = (E_NamePos)EditorGUILayout.EnumPopup("名字位置", asset.NamePos); asset.TalkerName = EditorGUILayout.TextField("角色名", asset.TalkerName); EditorGUIUtility.labelWidth = 90; asset.DubDelay = EditorGUILayout.IntField("配音等待字数", asset.DubDelay); asset.Dub = (AudioClip)EditorGUILayout.ObjectField("角色配音", asset.Dub, typeof(AudioClip), false); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); asset.LanguageType = (E_LanguageType)EditorGUILayout.EnumPopup("语言类型", asset.LanguageType); if (asset.LanguageType != _lastLanguageType) { _lastLanguageType = asset.LanguageType; } EditorGUILayout.EndHorizontal(); GUILayout.Label("事件列表"); _eventScrollPos = EditorGUILayout.BeginScrollView(_eventScrollPos, GUILayout.Height(90)); _talkEventList?.DoLayoutList(); EditorGUILayout.EndScrollView(); GUILayout.Label("对话内容"); EditorGUILayout.BeginHorizontal(); asset.LanguageDict.TryGetValue(asset.LanguageType, out ContentData data); data.Content = EditorGUILayout.TextArea(data.Content, GUILayout.Height(80)); if (GUILayout.Button("生成", GUILayout.Width(80), GUILayout.Height(80))) { data.WordList = new List <TyperRhythm>(); for (int i = 0; i < data.Content.Length; i++) { bool isDirective = false; string word = null; if (data.Content[i] == '<') { int count = 0; for (int j = i; j < data.Content.Length; j++) { word += data.Content[j]; if (data.Content[j] == '>') { Regex reg = new Regex(@"<c=[0-9a-fA-F]{6}"); if (word.Equals("<b>") || word.Equals("</b>") || reg.IsMatch(word) || word.Equals("</c>")) { isDirective = true; } break; } count++; } if (isDirective) { i += count; } else { word = data.Content[i].ToString(); } } else { word = data.Content[i].ToString(); } TyperRhythm typerWord = new TyperRhythm(word, 0.1f, isDirective); data.WordList.Add(typerWord); } //SaveDialogAsset(_curDialogAsset, _curDialogAsset); } EditorGUILayout.EndHorizontal(); if (data.WordList.Count > 0) { DrawTyperWordList(data.WordList); } }
/// <summary> /// Unity callback to draw a custom inspector. /// </summary> public override void OnInspectorGUI () { // Create styles? if (s_Styles == null) s_Styles = new InternalActionStateEditor.Styles(); // Workaround to update nodes if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") { GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; m_ActionState.LoadNodes(); UpdateActiveNode(); return; } // Reload nodes? if (m_ActionState.isDirty) { m_ActionState.LoadNodes(); UpdateActiveNode(); } // Register OnGUI node? if (!Application.isPlaying && m_ActionState.onGUINode != null && !GUICallback.HasCallbacks()) { this.RegisterEditorOnGUI(); } #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2 EditorGUIUtility.LookLikeInspector(); #endif // Draw default inspector DrawDefaultInspector(); // Shows the node editor? bool showNodeEditor = m_ActionState.parent == null || BehaviourWindow.activeState == m_ActionState; // Draw Action List if (m_NodeList == null) { // m_NodeList = new ReorderableList(this.serializedObject, this.serializedObject.FindProperty("m_UpdateActions")); m_NodeList = new ReorderableList(m_ActionState.GetNodes(), typeof(ActionNode)); m_NodeList.drawHeaderCallback += delegate (Rect rect) {EditorGUI.LabelField(rect, "Nodes");}; m_NodeList.drawElementCallback += DrawNode; m_NodeList.onAddCallback += this.OnAddNode; m_NodeList.onRemoveCallback += this.OnRemoveSelectedNode; m_NodeList.onSelectCallback += this.OnSelectNode; m_NodeList.onReorderCallback += this.OnReorderNode; // Select the active node UpdateActiveNode(); #if !UNITY_4_0_0 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 m_NodeList.list = m_ActionState.GetNodes(); m_NodeList.DoLayoutList(); #else this.Repaint(); #endif } else if (showNodeEditor) { m_NodeList.list = m_ActionState.GetNodes(); m_NodeList.DoLayoutList(); } if (showNodeEditor) { GUILayout.Space(6f); #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2 EditorGUIUtility.LookLikeControls(); #endif // Get the active node ActionNode activeNode = m_ActionState.isRoot ? this.GetActiveNode() : BehaviourWindow.activeNode; // Draw node properties if (m_NodeEditor != null) { // Is there an active node? if (activeNode != null && activeNode.owner as InternalActionState == m_ActionState) { // It's an Update node var oldGUIEnabled = GUI.enabled; GUI.enabled = !(activeNode is Update); m_NodeEditor.DrawNode(activeNode); GUI.enabled = oldGUIEnabled; GUILayout.Space(4f); } } // Copy/Paste/Cut/Duplicate/Delete keyboard shortcuts Event current = Event.current; if (current.type == EventType.ValidateCommand) { // Use event to call event ExecuteCommand if (current.commandName == "Paste") { ActionNode[] nodesToPaste = ActionStateUtility.GetActionsAndConditions(BehaviourTreeUtility.nodeToPaste != null ? new ActionNode[] {BehaviourTreeUtility.nodeToPaste} : new ActionNode[0]); if (nodesToPaste.Length > 0) current.Use(); } if (activeNode != null) { if (current.commandName == "Copy") current.Use(); else if (current.commandName == "Duplicate") current.Use(); else if (current.commandName == "Delete") current.Use(); else if (current.commandName == "Cut") current.Use(); } } else if (Event.current.type == EventType.ExecuteCommand) { if (current.commandName == "Paste") { ActionNode[] nodesToPaste = ActionStateUtility.GetActionsAndConditions(BehaviourTreeUtility.nodeToPaste != null ? new ActionNode[] {BehaviourTreeUtility.nodeToPaste} : new ActionNode[0]); ActionStateUtility.PasteNodes(m_ActionState, nodesToPaste); } else if (current.commandName == "Copy") BehaviourTreeUtility.nodeToPaste = activeNode; else if (current.commandName == "Duplicate") ActionStateUtility.PasteNodes(m_ActionState, new ActionNode[] {activeNode}); else if (current.commandName == "Delete") this.OnDestroyNode(activeNode); else if (current.commandName == "Cut") { BehaviourTreeUtility.nodeToPaste = activeNode; this.OnDestroyNode(activeNode); } } } }
public static void Draw(ReorderableList list) { list.DoLayoutList(); }
public override void OnInspectorGUI() { // Check Warnings //Debug.Log("OnInspectorGUI Called."); Event currentEvent = Event.current; serializedObject.Update(); GUILayout.Label("<b>TextMesh Pro! Font Asset</b>", TMP_UIStyleManager.Section_Label); // TextMeshPro Font Info Panel GUILayout.Label("Face Info", TMP_UIStyleManager.Section_Label); EditorGUI.indentLevel = 1; GUI.enabled = false; // Lock UI float labelWidth = EditorGUIUtility.labelWidth = 150f; float fieldWidth = EditorGUIUtility.fieldWidth; EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Name"), new GUIContent("Font Source")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("PointSize")); GUI.enabled = true; EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Scale")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("LineHeight")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Ascender")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("CapHeight")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Baseline")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Descender")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Underline"), new GUIContent("Underline Offset")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("strikethrough"), new GUIContent("Strikethrough Offset")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("SuperscriptOffset")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("SubscriptOffset")); SerializedProperty subSize_prop = m_fontInfo_prop.FindPropertyRelative("SubSize"); EditorGUILayout.PropertyField(subSize_prop, new GUIContent("Super / Subscript Size")); subSize_prop.floatValue = Mathf.Clamp(subSize_prop.floatValue, 0.25f, 1f); GUI.enabled = false; //EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Padding")); //GUILayout.Label("Atlas Size"); EditorGUI.indentLevel = 1; GUILayout.Space(18); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("Padding")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("AtlasWidth"), new GUIContent("Width")); EditorGUILayout.PropertyField(m_fontInfo_prop.FindPropertyRelative("AtlasHeight"), new GUIContent("Height")); GUI.enabled = true; EditorGUI.indentLevel = 0; GUILayout.Space(20); GUILayout.Label("Font Sub-Assets", TMP_UIStyleManager.Section_Label); GUI.enabled = false; EditorGUI.indentLevel = 1; EditorGUILayout.PropertyField(font_atlas_prop, new GUIContent("Font Atlas:")); EditorGUILayout.PropertyField(font_material_prop, new GUIContent("Font Material:")); GUI.enabled = true; string evt_cmd = Event.current.commandName; // Get Current Event CommandName to check for Undo Events // FONT SETTINGS EditorGUI.indentLevel = 0; if (GUILayout.Button("Font Weights\t" + (UI_PanelState.fontWeightPanel ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { UI_PanelState.fontWeightPanel = !UI_PanelState.fontWeightPanel; } if (UI_PanelState.fontWeightPanel) { EditorGUIUtility.labelWidth = 120; EditorGUILayout.BeginVertical(TMP_UIStyleManager.SquareAreaBox85G); EditorGUI.indentLevel = 0; GUILayout.Label("Select the Font Assets that will be used for the following font weights.", TMP_UIStyleManager.Label); GUILayout.Space(10f); EditorGUILayout.BeginHorizontal(); GUILayout.Label("<b>Font Weight</b>", TMP_UIStyleManager.Label, GUILayout.Width(117)); GUILayout.Label("<b>Normal Style</b>", TMP_UIStyleManager.Label); GUILayout.Label("<b>Italic Style</b>", TMP_UIStyleManager.Label); EditorGUILayout.EndHorizontal(); //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(1), new GUIContent("100 - Thin")); //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(2), new GUIContent("200 - Extra-Light")); //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(3), new GUIContent("300 - Light")); EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(4), new GUIContent("400 - Regular")); //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(5), new GUIContent("500 - Medium")); //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(6), new GUIContent("600 - Demi-Bold")); EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(7), new GUIContent("700 - Bold")); //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(8), new GUIContent("800 - Heavy")); //EditorGUILayout.PropertyField(fontWeights_prop.GetArrayElementAtIndex(9), new GUIContent("900 - Black")); EditorGUILayout.EndVertical(); //EditorGUI.indentLevel = 1; EditorGUIUtility.labelWidth = 120f; EditorGUILayout.BeginVertical(TMP_UIStyleManager.SquareAreaBox85G); GUILayout.Label("Settings used to simulate a typeface when no font asset is available.", TMP_UIStyleManager.Label); GUILayout.Space(5f); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(font_normalStyle_prop, new GUIContent("Normal Weight")); font_normalStyle_prop.floatValue = Mathf.Clamp(font_normalStyle_prop.floatValue, -3.0f, 3.0f); if (GUI.changed || evt_cmd == k_UndoRedo) { GUI.changed = false; // Modify the material property on matching material presets. for (int i = 0; i < m_materialPresets.Length; i++) { m_materialPresets[i].SetFloat("_WeightNormal", font_normalStyle_prop.floatValue); } } EditorGUILayout.PropertyField(font_boldStyle_prop, new GUIContent("Bold Weight"), GUILayout.MinWidth(100)); font_boldStyle_prop.floatValue = Mathf.Clamp(font_boldStyle_prop.floatValue, -3.0f, 3.0f); if (GUI.changed || evt_cmd == k_UndoRedo) { GUI.changed = false; // Modify the material property on matching material presets. for (int i = 0; i < m_materialPresets.Length; i++) { m_materialPresets[i].SetFloat("_WeightBold", font_boldStyle_prop.floatValue); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(font_normalSpacing_prop, new GUIContent("Spacing Offset")); font_normalSpacing_prop.floatValue = Mathf.Clamp(font_normalSpacing_prop.floatValue, -100, 100); if (GUI.changed || evt_cmd == k_UndoRedo) { GUI.changed = false; } EditorGUILayout.PropertyField(font_boldSpacing_prop, new GUIContent("Bold Spacing")); font_boldSpacing_prop.floatValue = Mathf.Clamp(font_boldSpacing_prop.floatValue, 0, 100); if (GUI.changed || evt_cmd == k_UndoRedo) { GUI.changed = false; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(font_italicStyle_prop, new GUIContent("Italic Style: ")); font_italicStyle_prop.intValue = Mathf.Clamp(font_italicStyle_prop.intValue, 15, 60); EditorGUILayout.PropertyField(font_tabSize_prop, new GUIContent("Tab Multiple: ")); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } GUILayout.Space(5); // FALLBACK FONT ASSETS EditorGUI.indentLevel = 0; if (GUILayout.Button("Fallback Font Assets\t" + (UI_PanelState.fallbackFontAssetPanel ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { UI_PanelState.fallbackFontAssetPanel = !UI_PanelState.fallbackFontAssetPanel; } if (UI_PanelState.fallbackFontAssetPanel) { EditorGUIUtility.labelWidth = 120; EditorGUILayout.BeginVertical(TMP_UIStyleManager.SquareAreaBox85G); EditorGUI.indentLevel = 0; GUILayout.Label("Select the Font Assets that will be searched and used as fallback when characters are missing from this font asset.", TMP_UIStyleManager.Label); GUILayout.Space(10f); m_list.DoLayoutList(); EditorGUILayout.EndVertical(); } // GLYPH INFO TABLE EditorGUIUtility.labelWidth = labelWidth; EditorGUIUtility.fieldWidth = fieldWidth; GUILayout.Space(5); EditorGUI.indentLevel = 0; if (GUILayout.Button("Glyph Info\t" + (UI_PanelState.glyphInfoPanel ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { UI_PanelState.glyphInfoPanel = !UI_PanelState.glyphInfoPanel; } if (UI_PanelState.glyphInfoPanel) { int arraySize = m_glyphInfoList_prop.arraySize; int itemsPerPage = 15; // Display Glyph Management Tools EditorGUILayout.BeginVertical(TMP_UIStyleManager.Group_Label, GUILayout.ExpandWidth(true)); { // Search Bar implementation #region DISPLAY SEARCH BAR EditorGUILayout.BeginHorizontal(); { EditorGUIUtility.labelWidth = 110f; EditorGUI.BeginChangeCheck(); string searchPattern = EditorGUILayout.TextField("Glyph Search", m_searchPattern, "SearchTextField"); if (EditorGUI.EndChangeCheck() || m_isSearchDirty) { if (string.IsNullOrEmpty(searchPattern) == false) { //GUIUtility.keyboardControl = 0; m_searchPattern = searchPattern; //.ToLower(System.Globalization.CultureInfo.InvariantCulture).Trim(); // Search Glyph Table for potential matches SearchGlyphTable(m_searchPattern, ref m_searchList); } m_isSearchDirty = false; } string styleName = string.IsNullOrEmpty(m_searchPattern) ? "SearchCancelButtonEmpty" : "SearchCancelButton"; if (GUILayout.Button(GUIContent.none, styleName)) { GUIUtility.keyboardControl = 0; m_searchPattern = string.Empty; } } EditorGUILayout.EndHorizontal(); #endregion // Display Page Navigation if (!string.IsNullOrEmpty(m_searchPattern)) { arraySize = m_searchList.Count; } DisplayGlyphPageNavigation(arraySize, itemsPerPage); } EditorGUILayout.EndVertical(); // Display Glyph Table Elements #region Glyph Table if (arraySize > 0) { // Display each GlyphInfo entry using the GlyphInfo property drawer. for (int i = itemsPerPage * m_GlyphPage; i < arraySize && i < itemsPerPage * (m_GlyphPage + 1); i++) { // Define the start of the selection region of the element. Rect elementStartRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)); int elementIndex = i; if (!string.IsNullOrEmpty(m_searchPattern)) { elementIndex = m_searchList[i]; } SerializedProperty glyphInfo = m_glyphInfoList_prop.GetArrayElementAtIndex(elementIndex); EditorGUI.BeginDisabledGroup(i != m_selectedElement); { EditorGUILayout.BeginVertical(TMP_UIStyleManager.Group_Label); EditorGUILayout.PropertyField(glyphInfo); EditorGUILayout.EndVertical(); } EditorGUI.EndDisabledGroup(); // Define the end of the selection region of the element. Rect elementEndRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)); // Check for Item selection Rect selectionArea = new Rect(elementStartRegion.x, elementStartRegion.y, elementEndRegion.width, elementEndRegion.y - elementStartRegion.y); if (DoSelectionCheck(selectionArea)) { m_selectedElement = i; m_AddGlyphWarning.isEnabled = false; m_unicodeHexLabel = k_placeholderUnicodeHex; GUIUtility.keyboardControl = 0; } // Draw Selection Highlight and Glyph Options if (m_selectedElement == i) { TMP_EditorUtility.DrawBox(selectionArea, 2f, new Color32(40, 192, 255, 255)); // Draw Glyph management options Rect controlRect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight * 1f); float optionAreaWidth = controlRect.width * 0.6f; float btnWidth = optionAreaWidth / 3; Rect position = new Rect(controlRect.x + controlRect.width * .4f, controlRect.y, btnWidth, controlRect.height); // Copy Selected Glyph to Target Glyph ID GUI.enabled = !string.IsNullOrEmpty(m_dstGlyphID); if (GUI.Button(position, new GUIContent("Copy to"))) { GUIUtility.keyboardControl = 0; // Convert Hex Value to Decimal int dstGlyphID = TMP_TextUtilities.StringToInt(m_dstGlyphID); //Add new glyph at target Unicode hex id. if (!AddNewGlyph(elementIndex, dstGlyphID)) { m_AddGlyphWarning.isEnabled = true; m_AddGlyphWarning.expirationTime = EditorApplication.timeSinceStartup + 1; } m_dstGlyphID = string.Empty; m_isSearchDirty = true; TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, m_fontAsset); } // Target Glyph ID GUI.enabled = true; position.x += btnWidth; GUI.SetNextControlName("GlyphID_Input"); m_dstGlyphID = EditorGUI.TextField(position, m_dstGlyphID); // Placeholder text EditorGUI.LabelField(position, new GUIContent(m_unicodeHexLabel, "The Unicode (Hex) ID of the duplicated Glyph"), TMP_UIStyleManager.Label); // Only filter the input when the destination glyph ID text field has focus. if (GUI.GetNameOfFocusedControl() == "GlyphID_Input") { m_unicodeHexLabel = string.Empty; //Filter out unwanted characters. char chr = Event.current.character; if ((chr < '0' || chr > '9') && (chr < 'a' || chr > 'f') && (chr < 'A' || chr > 'F')) { Event.current.character = '\0'; } } else { m_unicodeHexLabel = k_placeholderUnicodeHex; } // Remove Glyph position.x += btnWidth; if (GUI.Button(position, "Remove")) { GUIUtility.keyboardControl = 0; RemoveGlyphFromList(elementIndex); m_selectedElement = -1; m_isSearchDirty = true; TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, m_fontAsset); return; } if (m_AddGlyphWarning.isEnabled && EditorApplication.timeSinceStartup < m_AddGlyphWarning.expirationTime) { EditorGUILayout.HelpBox("The Destination Glyph ID already exists", MessageType.Warning); } } } } DisplayGlyphPageNavigation(arraySize, itemsPerPage); } #endregion // KERNING TABLE PANEL #region Kerning Table GUILayout.Space(5); if (GUILayout.Button("Kerning Table Info\t" + (UI_PanelState.kerningInfoPanel ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { UI_PanelState.kerningInfoPanel = !UI_PanelState.kerningInfoPanel; } if (UI_PanelState.kerningInfoPanel) { Rect pos; SerializedProperty kerningPairs_prop = m_kerningInfo_prop.FindPropertyRelative("kerningPairs"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Left Char", TMP_UIStyleManager.TMP_GUISkin.label); GUILayout.Label("Right Char", TMP_UIStyleManager.TMP_GUISkin.label); GUILayout.Label("Offset Value", TMP_UIStyleManager.TMP_GUISkin.label); GUILayout.Label(GUIContent.none, GUILayout.Width(20)); EditorGUILayout.EndHorizontal(); GUILayout.BeginVertical(TMP_UIStyleManager.TMP_GUISkin.label); int arraySize = kerningPairs_prop.arraySize; int itemsPerPage = 25; if (arraySize > 0) { // Display each GlyphInfo entry using the GlyphInfo property drawer. for (int i = itemsPerPage * m_KerningPage; i < arraySize && i < itemsPerPage * (m_KerningPage + 1); i++) { SerializedProperty kerningPair_prop = kerningPairs_prop.GetArrayElementAtIndex(i); pos = EditorGUILayout.BeginHorizontal(); EditorGUI.PropertyField(new Rect(pos.x, pos.y, pos.width - 20f, pos.height), kerningPair_prop, GUIContent.none); // Button to Delete Kerning Pair if (GUILayout.Button("-", GUILayout.ExpandWidth(false))) { m_kerningTable.RemoveKerningPair(i); m_fontAsset.ReadFontDefinition(); // Reload Font Definition. serializedObject.Update(); // Get an updated version of the SerializedObject. isAssetDirty = true; break; } EditorGUILayout.EndHorizontal(); } } Rect pagePos = EditorGUILayout.GetControlRect(false, 20); pagePos.width /= 3; int shiftMultiplier = currentEvent.shift ? 10 : 1; // Previous Page if (m_KerningPage > 0) { GUI.enabled = true; } else { GUI.enabled = false; } if (GUI.Button(pagePos, "Previous Page")) { m_KerningPage -= 1 * shiftMultiplier; } // Page Counter GUI.enabled = true; pagePos.x += pagePos.width; int totalPages = (int)(arraySize / (float)itemsPerPage + 0.999f); GUI.Label(pagePos, "Page " + (m_KerningPage + 1) + " / " + totalPages, GUI.skin.button); // Next Page pagePos.x += pagePos.width; if (itemsPerPage * (m_GlyphPage + 1) < arraySize) { GUI.enabled = true; } else { GUI.enabled = false; } if (GUI.Button(pagePos, "Next Page")) { m_KerningPage += 1 * shiftMultiplier; } m_KerningPage = Mathf.Clamp(m_KerningPage, 0, arraySize / itemsPerPage); GUILayout.EndVertical(); GUILayout.Space(10); // Add New Kerning Pair Section GUILayout.BeginVertical(TMP_UIStyleManager.SquareAreaBox85G); pos = EditorGUILayout.BeginHorizontal(); // Draw Empty Kerning Pair EditorGUI.PropertyField(new Rect(pos.x, pos.y, pos.width - 20f, pos.height), m_kerningPair_prop); GUILayout.Label(GUIContent.none, GUILayout.Height(19)); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); if (GUILayout.Button("Add New Kerning Pair")) { int asci_left = m_kerningPair_prop.FindPropertyRelative("AscII_Left").intValue; int asci_right = m_kerningPair_prop.FindPropertyRelative("AscII_Right").intValue; float xOffset = m_kerningPair_prop.FindPropertyRelative("XadvanceOffset").floatValue; errorCode = m_kerningTable.AddKerningPair(asci_left, asci_right, xOffset); // Sort Kerning Pairs & Reload Font Asset if new kerning pair was added. if (errorCode != -1) { m_kerningTable.SortKerningPairs(); m_fontAsset.ReadFontDefinition(); // Reload Font Definition. serializedObject.Update(); // Get an updated version of the SerializedObject. isAssetDirty = true; } else { timeStamp = System.DateTime.Now.AddSeconds(5); } } if (errorCode == -1) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Kerning Pair already <color=#ffff00>exists!</color>", TMP_UIStyleManager.Label); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (System.DateTime.Now > timeStamp) { errorCode = 0; } } GUILayout.EndVertical(); } #endregion if (serializedObject.ApplyModifiedProperties() || evt_cmd == k_UndoRedo || isAssetDirty) { //Debug.Log("Serialized properties have changed."); TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, m_fontAsset); isAssetDirty = false; EditorUtility.SetDirty(target); //TMPro_EditorUtility.RepaintAll(); // Consider SetDirty } // Clear selection if mouse event was not consumed. GUI.enabled = true; if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0) { m_selectedElement = -1; } }
public override void DrawWindow() { if (currentState == null) { EditorGUILayout.LabelField("Add state to modify:"); } else { if (collapse) { windowRect.height = 100; } collapse = EditorGUILayout.Toggle("Collapse", collapse); } currentState = EditorGUILayout.ObjectField(currentState, typeof(State), false) as State; if (previousState != currentState) { serializedState = null; previousState = currentState; /* * ClearReferences(); * for (int i = 0; i < currentState.transitions.Count; i++) * { * dependencies.Add(BehaviorEditor.AddTransitionNode(i, currentState.transitions[i], this)); * } */ } if (currentState != null) { if (serializedState == null) { serializedState = new SerializedObject(currentState); onStateList = new ReorderableList(serializedState, serializedState.FindProperty("onState"), true, true, true, true); onEnterList = new ReorderableList(serializedState, serializedState.FindProperty("onEnter"), true, true, true, true); onExitList = new ReorderableList(serializedState, serializedState.FindProperty("onExit"), true, true, true, true); } if (!collapse) { serializedState.Update(); HandleReordableList(onStateList, "On State"); HandleReordableList(onEnterList, "On Enter"); HandleReordableList(onExitList, "On Exit"); EditorGUILayout.LabelField(""); onStateList.DoLayoutList(); EditorGUILayout.LabelField(""); onEnterList.DoLayoutList(); EditorGUILayout.LabelField(""); onExitList.DoLayoutList(); serializedState.ApplyModifiedProperties(); float standard = 300; standard += onStateList.count * 20; windowRect.height = standard; } } }
private void OnGUI() { // Style initialization if (!init) { Initialize(); init = true; } // Create animation box NewAnimationBox(); if (justCreatedAnim) { justCreatedAnim = false; return; } // Edit animation box EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); { // Animation asset field if (selectedAnimation == null) { EditorGUILayout.BeginVertical(box); selectedAnimation = EditorGUILayout.ObjectField("Animation", selectedAnimation, typeof(SpriteAnimation), false) as SpriteAnimation; EditorGUILayout.EndVertical(); } else { // Init reorderable list if (frameList == null) { InitializeReorderableList(); } // Add the frames dropped on the drag and drop box if (draggedSprites != null && draggedSprites.Count > 0) { // TODO Record Undo/Redo for dragged sprites, currently not working, don't know why //Undo.RecordObject(selectedAnimation, "Add Frames"); for (int i = 0; i < draggedSprites.Count; i++) { AddFrame(draggedSprites[i]); } draggedSprites.Clear(); SaveFile(true); } // Retrocompatibility check for the new frames duration field if (selectedAnimation.FramesCount != selectedAnimation.FramesDuration.Count) { selectedAnimation.FramesDuration.Clear(); for (int i = 0; i < selectedAnimation.FramesCount; i++) { selectedAnimation.FramesDuration.Add(1); } } // Config settings ConfigBox(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { // Preview window setup Rect previewRect = EditorGUILayout.BeginVertical(lowPaddingBox, GUILayout.MaxWidth(position.width / 2)); PreviewBox(previewRect); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); { // FPS int fps = selectedAnimation.FPS; EditorGUI.BeginChangeCheck(); { fps = EditorGUILayout.IntField("FPS", selectedAnimation.FPS); } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(selectedAnimation, "Change FPS"); selectedAnimation.FPS = fps; if (selectedAnimation.FPS < 0) { selectedAnimation.FPS = 0; } } EditorGUILayout.Space(); scrollWindowPosition = EditorGUILayout.BeginScrollView(scrollWindowPosition); { // Individual frames frameList.displayRemove = (selectedAnimation.FramesCount > 0); frameList.DoLayoutList(); EditorGUILayout.Space(); } EditorGUILayout.EndScrollView(); EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); // Check Events Event evt = Event.current; switch (evt.type) { // Delete frames with supr case EventType.KeyDown: if (Event.current.keyCode == KeyCode.Delete && selectedAnimation.FramesCount > 0 && frameList.HasKeyboardControl() && frameListSelectedIndex != -1) { RemoveFrameListItem(frameList); } break; // Zoom preview window with scrollwheel case EventType.ScrollWheel: if (spritePreview != null) { Vector2 mpos = Event.current.mousePosition; if (mpos.x >= previewRect.x && mpos.x <= previewRect.x + previewRect.width && mpos.y >= previewRect.y && mpos.y <= previewRect.y + previewRect.height) { Repaint(); spritePreview.Zoom = -evt.delta.y; } } break; } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); if (GUI.changed && selectedAnimation != null) { SaveFile(); } }
public override void OnInspectorGUI() { _componentTagList.DoLayoutList(); }
public override void OnGUI() { base.OnGUI(); if (Current != null) { GUI.enabled = false; EditorGUILayout.ObjectField("Current ActionList", Current, typeof(ActionList), true); GUI.enabled = true; EditorGUI.BeginChangeCheck(); obj.Update(); SerializedProperty property = obj.GetIterator(); bool enterChildren = true; while (property.NextVisible(enterChildren)) { using (new EditorGUI.DisabledScope("m_Script" == property.propertyPath)) { if (property.propertyType == SerializedPropertyType.Generic && property.type == "vector") { InspectorPlus.Singleton singleAtt = PropertyDrawerTools.GetAttribute <InspectorPlus.Singleton>(property); if (singleAtt != null) { IList listInstance = PropertyDrawerTools.GetPropertyInstance <IList>(property); if (listInstance != null) { for (int i = 0; i < listInstance.Count; i++) { var listElement = listInstance[i]; for (int j = listInstance.Count - 1; j > i; j--) { var listElement1 = listInstance[j]; if (listElement == listElement1) { listInstance.RemoveAt(j); } } } } } InspectorPlus.Orderable att = PropertyDrawerTools.GetAttribute <InspectorPlus.Orderable>(property); if (att != null) { ReorderableList list = RecorderLists[property.name]; currentList = list; bool show = EditorPrefs.GetBool(property.propertyPath); show = EditorGUILayout.Foldout(show, property.name); if (show) { list.DoLayoutList(); foreach (int i in deleteList) { property.DeleteArrayElementAtIndex(i); } deleteList.Clear(); } EditorPrefs.SetBool(property.propertyPath, show); } else { EditorGUILayout.PropertyField(property, true, new GUILayoutOption[0]); } } else { EditorGUILayout.PropertyField(property, true, new GUILayoutOption[0]); } } enterChildren = false; } obj.ApplyModifiedProperties(); EditorGUI.EndChangeCheck(); } DebugAllList(); DebugAllPack(); DebugPlayer(); DebugActions(); }
/// <summary> /// Draws in the content area of the window /// </summary> public override void DrawContent() { // Stop if no link is selected if (Editor.Canvas.SelectedLink == null) { mTarget = null; return; } bool lHasChanged = (mTarget != Editor.Canvas.SelectedLink); mIsDirty = false; mTarget = Editor.Canvas.SelectedLink; // Update the list if a new target is selected if (mActionList == null || lHasChanged) { if (mTarget.Actions == null) { mTarget.Actions = new List <NodeLinkAction>(); } InstantiateActionList(); } if (mActionList != null) { if (mActionList.index >= mActionList.count) { mActionList.index = mActionList.count - 1; } if (mEditorActionIndex >= mActionList.count) { mEditorActionIndex = mActionList.count - 1; } } // Edit the link if (EditorHelper.BoolField("Is Enabled", "Determines if the link can be traversed.", mTarget.IsEnabled, Editor.RootAsset)) { mIsDirty = true; mTarget.IsEnabled = EditorHelper.FieldBoolValue; } if (EditorHelper.TextField("Name", "Name used to help identify the link.", mTarget.Name, Editor.RootAsset)) { mIsDirty = true; mTarget.Name = EditorHelper.FieldStringValue; } GUILayout.Space(5f); // Show the items GUILayout.BeginVertical(NodeEditorStyle.GroupBox); mActionList.DoLayoutList(); if (mActionList.index >= 0 && mActionList.index < mActionList.count) { GUILayout.Space(5f); GUILayout.BeginVertical(NodeEditorStyle.Box); bool lListIsDirty = DrawActionDetailItem(mTarget.Actions[mActionList.index]); if (lListIsDirty) { mIsDirty = true; } GUILayout.EndVertical(); } EditorGUILayout.EndVertical(); if (mIsDirty) { EditorUtility.SetDirty(mTarget); Editor.SetDirty(); } }
public override void OnInspectorGUI() { m_LabelsList.DoLayoutList(); }