private void OnEnable() { wantsMouseMove = true; if (chapterMenu == null) { chapterMenu = CreateInstance <TrainingMenuView>(); } if (chapterRepresentation == null) { #if CREATOR_PRO chapterRepresentation = new ProChapterRepresentation(); #else chapterRepresentation = new ChapterRepresentation(); #endif chapterRepresentation.Graphics.Canvas.PointerDrag += (o, eventArgs) => currentScrollPosition -= eventArgs.PointerDelta; } if (titleIcon == null) { titleIcon = new EditorIcon("icon_training_editor"); } EditorSceneManager.newSceneCreated += OnNewScene; EditorSceneManager.sceneOpened += OnSceneOpened; GlobalEditorHandler.CourseWindowOpened(this); }
private GameObject AddMouseQuad(EditorIcon icon, int subIdx, float scale = 1f) { scale *= quadBaseScale; GameObject quad = CreateQuad(); VisualResources.SetIconUV(icon, subIdx, quad); quad.transform.localScale = new Vector3(scale, scale, scale); return quad; }
private void LoadIcons() { deleteIcon = new EditorIcon("icon_delete"); arrowUpIcon = new EditorIcon("icon_arrow_up"); arrowDownIcon = new EditorIcon("icon_arrow_down"); editIcon = new EditorIcon("icon_edit"); folderIcon = new EditorIcon("icon_folder"); chapterMenuExpandIcon = new EditorIcon("icon_expand_chapter"); chapterMenuCollapseIcon = new EditorIcon("icon_collapse_chapter"); }
protected void AddModule <Module>(string path, EditorIcon icon = null) where Module : AEditorModule { if (null == icon) { menuTree.Add(path, Activator.CreateInstance(typeof(Module), new object[] { this })); } else { menuTree.Add(path, Activator.CreateInstance(typeof(Module), new object[] { this }), icon); } }
private void OnGUI() { // Magic number. minSize = new Vector2(420f, 320f); titleContent = new GUIContent("Training Course Wizard"); GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.richText = true; labelStyle.wordWrap = true; EditorIcon logo = new EditorIcon("logo_creator"); Rect rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box); GUI.DrawTexture(rect, logo.Texture, ScaleMode.ScaleToFit); if (RuntimeConfigurator.Exists == false) { EditorGUILayout.HelpBox("The current scene is not a training scene. No course can be created. To automatically setup the scene, select \"Innoactive > Setup Training Scene\".", MessageType.Error); } EditorGUI.BeginDisabledGroup(RuntimeConfigurator.Exists == false); EditorGUILayout.LabelField("<b>Create a new training course.</b>", labelStyle); courseName = EditorGUILayout.TextField(new GUIContent("Training Course Name", "Set a file name for the new training course."), courseName); EditorGUILayout.LabelField("The new course will be set for the current scene."); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // ReSharper disable once InvertIf if (GUILayout.Button("Create", GUILayout.Width(128), GUILayout.Height(32))) { if (CourseAssetUtils.CanCreate(courseName, out errorMessage)) { CourseAssetManager.Import(EntityFactory.CreateCourse(courseName)); RuntimeConfigurator.Instance.SetSelectedCourse(CourseAssetUtils.GetCourseStreamingAssetPath(courseName)); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); GlobalEditorHandler.SetCurrentCourse(courseName); GlobalEditorHandler.StartEditingCourse(); Close(); } } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (string.IsNullOrEmpty(errorMessage) == false) { EditorGUILayout.HelpBox(errorMessage, MessageType.Error); } }
static EditorIcons() { TriangleRight = new EditorIcon(Database.TriangleRight); TriangleDown = new EditorIcon(Database.TriangleRight.Rotate()); AssemblyReloadEvents.beforeAssemblyReload += () => { TriangleRight.Dispose(); TriangleDown.Dispose(); }; }
bool DrawSwitchButton(EditorIcon icon) { EditorGUILayout.BeginVertical(); EditorGUILayout.GetControlRect(GUILayout.Height(15), GUILayout.Width(0)); bool wasButtonClicked = SirenixEditorGUI.IconButton(icon); EditorGUILayout.GetControlRect(GUILayout.Height(5), GUILayout.Width(0)); EditorGUILayout.EndVertical(); return(wasButtonClicked); }
private void OnTitleBarGUI(List <ModelActionEditor> actionEditors, ref bool state) { EditorIcon icon = state ? EditorIcons.X : EditorIcons.Checkmark; if (SirenixEditorGUI.ToolbarButton(icon)) { state = !state; foreach (var item in actionEditors) { item.IsSelected = state; } } }
public void AddAEditorWindowBase <EditorWindowBase>(string path, EditorIcon icon = null) where EditorWindowBase : AEditorWindowBase { AEditorWindowBase aEditorWindowBase = (AEditorWindowBase)Activator.CreateInstance(typeof(EditorWindowBase), new object[] { this }); if (icon == null) { OdinMenuTree.Add(path, aEditorWindowBase); } else { OdinMenuTree.Add(path, aEditorWindowBase, icon); } aEditorWindowBaseList.Add(aEditorWindowBase); }
protected void AddModule <Module>(string path, EditorIcon icon = null) where Module : AEditorModule { var module = Activator.CreateInstance(typeof(Module), new object[] { this }) as AEditorModule; if (null == icon) { menuTree.Add(path, module); } else { menuTree.Add(path, module, icon); } _modules.Add(module); }
public void AddEntity(EntityData entity) { if (objectIcons[entity.TilePosition.x, entity.TilePosition.y] != null) { Destroy(objectIcons[entity.TilePosition.x, entity.TilePosition.y].gameObject); objectIcons[entity.TilePosition.x, entity.TilePosition.y] = null; } EditorIcon icon = Instantiate(iconPrefab, objectsLayer); icon.transform.position = GetMapTilePosition(entity.TilePosition); Debug.Log("Placing a " + entity.EntityType.ToString()); icon.SetIcon(objectSprites[(int)entity.EntityType]); room.entityData[entity.TilePosition.x, entity.TilePosition.y] = entity; objectIcons[entity.TilePosition.x, entity.TilePosition.y] = icon; }
private void LoadIconTextures() { var textFile = Resources.Load <TextAsset>("UnityEditorIcons"); var paths = textFile.text.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries); this.icons = new EditorIcon[paths.Length]; for (int i = 0; i < paths.Length; ++i) { var path = paths[i]; var icon = new EditorIcon(); icon.Path = path; icon.Texture = EditorGUIUtility.IconContent(path).image; icon.GUIContent = new GUIContent(icon.Path, icon.Texture); this.icons[i] = icon; } }
public void AddNPCEntity(NPCData entity) { if (objectIcons[entity.TilePosition.x, entity.TilePosition.y] != null) { Destroy(objectIcons[entity.TilePosition.x, entity.TilePosition.y].gameObject); objectIcons[entity.TilePosition.x, entity.TilePosition.y] = null; } EditorIcon icon = Instantiate(iconPrefab, objectsLayer); icon.transform.position = GetMapTilePosition(entity.TilePosition) + new Vector2(0, -16); icon.SetIcon(NPCsprite); room.entityData[entity.TilePosition.x, entity.TilePosition.y] = entity; objectIcons[entity.TilePosition.x, entity.TilePosition.y] = icon; }
private void OnEnable() { wantsMouseMove = true; if (chapterMenu == null) { chapterMenu = CreateInstance <TrainingMenuView>(); } if (chapterRepresentation == null) { chapterRepresentation = new ChapterRepresentation(); chapterRepresentation.Graphics.Canvas.PointerDrag += (o, eventArgs) => currentScrollPosition -= eventArgs.PointerDelta; } if (titleIcon == null) { titleIcon = new EditorIcon("icon_training_editor"); } if (window != null && window != this) { window.Close(); } window = this; if (string.IsNullOrEmpty(temporarySerializedTraining) == false) { try { bool wasDirty = IsDirty; chapterMenu = CreateInstance <TrainingMenuView>(); SetTrainingCourse(JsonTrainingSerializer.Deserialize(temporarySerializedTraining)); IsDirty = wasDirty; temporarySerializedTraining = null; } catch (Exception e) { logger.Error("Couldn't restore the training course state.", e); } } }
private static void Draw(int id, Rect rect) { if (ohsStatic == null || ohsStatic.enabled == false) { return; } GameObject gameObject = EditorUtility.InstanceIDToObject(id) as GameObject; if (gameObject == null) { return; } Rect extended = new Rect(rect); extended.xMin = extended.xMin - 2; OdinHierarchySettings.Item item = ohsStatic.MatchSettingsWithGameObject(gameObject); if (item != null) { Rect rectToUse = extended; GUIStyle style; switch (item.style) { case OdinHierarchySettings.Style.Off: style = SirenixGUIStyles.None; break; case OdinHierarchySettings.Style.A1: style = SirenixGUIStyles.Button; break; case OdinHierarchySettings.Style.A2: style = EditorStyles.miniButton; break; case OdinHierarchySettings.Style.A3: style = EditorStyles.miniButtonMid; break; case OdinHierarchySettings.Style.A4: style = EditorStyles.helpBox; break; case OdinHierarchySettings.Style.B1: style = EditorStyles.whiteLabel; break; case OdinHierarchySettings.Style.B2: style = EditorStyles.whiteMiniLabel; break; default: style = SirenixGUIStyles.None; break; } style = new GUIStyle(style); style.alignment = item.textAnchor; GUIHelper.PushColor(item.color); string textToDraw = string.IsNullOrEmpty(item.overrideText) ? gameObject.name : item.overrideText; EditorGUI.LabelField(rectToUse, item.drawText ? textToDraw : "", style); GUIHelper.PopColor(); if (item.decoration) { if (item.decorationType == OdinHierarchySettings.Decoration.Highlight) { SirenixEditorGUI.DrawSolidRect(rectToUse, item.decorationColor); } if (item.decorationType == OdinHierarchySettings.Decoration.Underline) { SirenixEditorGUI.DrawBorders(rectToUse, 0, 0, 0, 1, item.decorationColor); } if (item.decorationType == OdinHierarchySettings.Decoration.Left) { //Rect extended2 = new Rect(extended); extended.xMin = extended.xMin - 2; SirenixEditorGUI.DrawBorders(extended, 4, 0, 0, 0, item.decorationColor); } if (item.decorationType == OdinHierarchySettings.Decoration.Right) { SirenixEditorGUI.DrawBorders(rectToUse, 0, 4, 0, 0, item.decorationColor); } } if (item.icon && string.IsNullOrEmpty(item.iconName) == false) { EditorIcon editorIcon = (EditorIcon)iconProperties[item.iconName].GetGetMethod().Invoke(null, null); float iconSize = ohsStatic.baseIconSize + item.iconSizeAdded; var rightPadding = ohsStatic.baseIconRightPadding + item.iconRightPaddingAdded; EditorGUIUtility.SetIconSize(new Vector2(iconSize, iconSize)); var iconRect = new Rect(rect.xMax - (iconSize + rightPadding), rect.yMin + ((rect.height - iconSize) / 2.0f), iconSize + rightPadding, iconSize); //SirenixEditorGUI.DrawSolidRect(iconDrawRect, Color.yellow); //For debugging var iconContent = new GUIContent(editorIcon.Active); EditorGUI.LabelField(iconRect, iconContent, SirenixGUIStyles.None); EditorGUIUtility.SetIconSize(Vector2.zero); } } }
internal static void SetIconUV(EditorIcon icon, int subIdx, GameObject quad) { InitSpriteSheet(); Rect sourceRect; float size = 1; GetIconRect(icon, subIdx, out sourceRect, out size); if (quad != null) { Renderer renderer = quad.GetComponent<Renderer>(); if(renderer != null && renderer.sharedMaterial != null){ renderer.sharedMaterial.SetTexture("_MainTex", iconSpriteSheet); renderer.sharedMaterial.SetTextureOffset("_MainTex", new Vector2(sourceRect.x, sourceRect.y)); renderer.sharedMaterial.SetTextureScale("_MainTex", new Vector2(sourceRect.width, sourceRect.height)); } } }
private static void GetIconRect(EditorIcon icon, int subIdx, out Rect sourceRect, out float size) { ushort safeSubIdx = subIdx < 0 ? (ushort)255 : (ushort)subIdx; ushort key = (ushort)((int)icon << 8 | safeSubIdx); size = 1f; if (sourceLocations.ContainsKey(key)) { sourceRect = sourceLocations[key]; size = sourceSizes[key]; } else { int iconIdx = (int)icon - 1; float collums = 4; float idY = Mathf.Floor(iconIdx / collums); float idX = iconIdx - (idY * collums); float rato = (float)iconSpriteSheet.width / (float)iconSpriteSheet.height; float localSizeX = 1f / collums; float localSizeY = localSizeX * rato; float sourceX = idX / collums; float sourceY = (1f - (idY / collums) * rato) - localSizeY; size = (float)iconSpriteSheet.width / (float)collums; if (subIdx != -1) { size /= 2; localSizeX /= 2; localSizeY /= 2; float subIdxX = Mathf.Floor(subIdx / 2); float subIdxY = subIdx - (subIdxX * 2); sourceX += subIdxX * localSizeX; sourceY += subIdxY * localSizeY; } sourceRect = new Rect(sourceX, sourceY, localSizeX, localSizeY); sourceLocations.Add(key, sourceRect); sourceSizes.Add(key, size); } }
public CsharpScaffoldQuickCaller() { csharpScaffoldIcon = EditorIcon.CreateIcon (iconDirectory.Value, "csharp_scaffold_white_icon" , "csharp_scaffold_black_icon"); }
private void OnGUI() { // Magic number. minSize = new Vector2(420f, 320f); titleContent = new GUIContent("Training Course Wizard"); GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.richText = true; labelStyle.wordWrap = true; EditorIcon logo = new EditorIcon("logo_creator"); Rect rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box); GUI.DrawTexture(rect, logo.Texture, ScaleMode.ScaleToFit); if (RuntimeConfigurator.Exists == false) { EditorGUILayout.HelpBox("The current scene is not a training scene. No course can be created. To automatically setup the scene, select \"Innoactive > Training > Setup Current Scene as Training Scene\".", MessageType.Error); } EditorGUI.BeginDisabledGroup(RuntimeConfigurator.Exists == false); EditorGUILayout.LabelField("<b>Create a new training course.</b>", labelStyle); trainingName = EditorGUILayout.TextField(new GUIContent("Training Course Name", "Set a file name for the new training course."), trainingName); EditorGUILayout.LabelField("The new course will be set for the current scene."); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // ReSharper disable once InvertIf if (GUILayout.Button("Create", GUILayout.Width(128), GUILayout.Height(32))) { int invalidCharacterIndex; if (string.IsNullOrEmpty(trainingName)) { errorMessage = "Training course name is empty!"; } else if ((invalidCharacterIndex = trainingName.IndexOfAny(Path.GetInvalidFileNameChars())) >= 0) { errorMessage = string.Format("Course name contains invalid character: {0}", trainingName[invalidCharacterIndex]); } else { string trainingCoursePath = SaveManager.GetTrainingPath(trainingName); string trainingCourseFolder = Path.GetDirectoryName(trainingCoursePath); if (Directory.Exists(trainingCourseFolder)) { errorMessage = string.Format("Training course with name \"{0}\" already exists!", trainingName); } else { TrainingWindow trainingWindow = TrainingWindow.GetWindow(); trainingWindow.Focus(); ICourse course = CreateCourse(); if (trainingWindow.SetTrainingCourseWithUserConfirmation(course)) { SaveManager.SaveTrainingCourseToFile(course); RuntimeConfigurator.SetSelectedTrainingCourse(trainingCoursePath.Substring(Application.streamingAssetsPath.Length + 1)); Close(); } } } } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (string.IsNullOrEmpty(errorMessage) == false) { EditorGUILayout.HelpBox(errorMessage, MessageType.Error); } }
public static Rect DrawIcon(EditorIcon icon, int subIdx, Vector2 pos, float scale = 1f, bool center = true) { if (icon == EditorIcon.none) return new Rect(); InitSpriteSheet(); if (iconSpriteSheet == null) return new Rect(); Rect sourceRect; float size = 1f; GetIconRect(icon, subIdx, out sourceRect, out size); pos.x = Mathf.Round(pos.x); pos.y = Mathf.Round(pos.y); size *= scale; if (center) { float half = (size / 2); pos.x -= half; pos.y -= half; } Rect destRect = new Rect(pos.x, pos.y, size, size); VisualResources.DrawTextureWithTexCoords(destRect, iconSpriteSheet, sourceRect); return destRect; }
/// <summary> /// Assigns the specified icon to the last menu item in the collection. /// </summary> public static IEnumerable <OdinMenuItem> AddIcon(this IEnumerable <OdinMenuItem> menuItems, EditorIcon icon) { menuItems.AddIcon(icon.Highlighted, icon.Raw); return(menuItems); }
/// <summary>Retrieves an icon that represents a specific generic editor icon.</summary> public static SpriteTexture GetEditorIcon(EditorIcon icon) { return(Internal_getEditorIcon(icon)); }
private void DrawRootTypeGroup(InspectorDefaultEditors editorCategory, IPropertyValueEntry <InspectorTypeDrawingConfig> entry, string searchText) { TypeGroup typeGroup; switch (editorCategory) { case InspectorDefaultEditors.UserTypes: typeGroup = UserTypesRootGroup; break; case InspectorDefaultEditors.PluginTypes: typeGroup = PluginTypesRootGroup; break; case InspectorDefaultEditors.UnityTypes: typeGroup = UnityTypesRootGroup; break; case InspectorDefaultEditors.OtherTypes: default: typeGroup = OtherTypesRootGroup; break; } if (typeGroup.SubTypes.Count == 0 && typeGroup.SubGroups.Count == 0) { SirenixEditorGUI.BeginListItem(); { SirenixEditorGUI.BeginIndentedHorizontal(); { GUIHelper.PushGUIEnabled(false); { SirenixEditorGUI.IconButton(EditorIcons.TriangleRight, IconStyle, 16); GUILayoutUtility.GetRect(16, 16, EditorStyles.toggle, GUILayoutOptions.ExpandWidth(false).Width(16)); GUILayout.Label(typeGroup.Name); } GUIHelper.PopGUIEnabled(); } SirenixEditorGUI.EndIndentedHorizontal(); } SirenixEditorGUI.EndListItem(); } else { bool useToggle = true; var rect = SirenixEditorGUI.BeginListItem(); { bool toggleExpansion = false; SirenixEditorGUI.BeginIndentedHorizontal(); { EditorIcon icon = (typeGroup.IsExpanded || !searchText.IsNullOrWhitespace()) ? EditorIcons.TriangleDown : EditorIcons.TriangleRight; toggleExpansion = SirenixEditorGUI.IconButton(icon, IconStyle, 16); if (useToggle) { EditorGUI.showMixedValue = typeGroup.HasConflict; bool isToggled = typeGroup.HasConflict || typeGroup.GetSharedEditorType() == typeof(OdinEditor); GUI.changed = false; isToggled = EditorGUI.Toggle(GUILayoutUtility.GetRect(16, 16, EditorStyles.toggle, GUILayoutOptions.ExpandWidth(false).Width(16)), isToggled); if (GUI.changed) { typeGroup.ClearEditorTypes(); if (isToggled) { // Add rule flag InspectorConfig.Instance.DefaultEditorBehaviour |= editorCategory; } else { // Remove rule flag InspectorConfig.Instance.DefaultEditorBehaviour = InspectorConfig.Instance.DefaultEditorBehaviour & ~editorCategory; } EditorUtility.SetDirty(InspectorConfig.Instance); InspectorConfig.Instance.UpdateOdinEditors(); } EditorGUI.showMixedValue = false; } else { GUILayout.Label("TODO: DROPDOWN!"); } GUILayout.Label(typeGroup.Name); } SirenixEditorGUI.EndIndentedHorizontal(); if (toggleExpansion || (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))) { typeGroup.IsExpanded = !typeGroup.IsExpanded; Event.current.Use(); } } SirenixEditorGUI.EndListItem(); if (SirenixEditorGUI.BeginFadeGroup(typeGroup, typeGroup.IsExpanded || !searchText.IsNullOrWhitespace())) { EditorGUI.indentLevel++; foreach (var subType in typeGroup.SubTypes) { if (typeGroup.IsTypeVisible(subType.DrawnType)) { this.DrawType(subType, entry); } } foreach (var subGroup in typeGroup.SubGroups) { this.DrawTypeGroup(subGroup, entry, searchText); } EditorGUI.indentLevel--; } SirenixEditorGUI.EndFadeGroup(); } }
private void DrawTypeGroup(TypeGroup typeGroup, IPropertyValueEntry <InspectorTypeDrawingConfig> entry, string searchText) { if (!typeGroup.IsSearchVisible) { return; } bool useToggle = true; var rect = SirenixEditorGUI.BeginListItem(); { bool toggleExpansion = false; SirenixEditorGUI.BeginIndentedHorizontal(); { EditorIcon icon = (typeGroup.IsExpanded || !searchText.IsNullOrWhitespace()) ? EditorIcons.TriangleDown : EditorIcons.TriangleRight; toggleExpansion = SirenixEditorGUI.IconButton(icon, IconStyle, 16); if (!typeGroup.HasEligibleTypes) { toggleExpansion |= SirenixEditorGUI.IconButton(EditorIcons.Transparent, 20); } else { if (useToggle) { EditorGUI.showMixedValue = typeGroup.HasConflict; bool isToggled = typeGroup.HasConflict || typeGroup.GetSharedEditorType() == typeof(OdinEditor); GUI.changed = false; isToggled = EditorGUI.Toggle(GUILayoutUtility.GetRect(16, 16, EditorStyles.toggle, GUILayoutOptions.ExpandWidth(false).Width(16)), isToggled); if (GUI.changed) { typeGroup.SetSharedEditorType(isToggled ? typeof(OdinEditor) : null); UpdateRootGroupConflicts(); InspectorConfig.Instance.UpdateOdinEditors(); } EditorGUI.showMixedValue = false; } else { GUILayout.Label("TODO: DROPDOWN!"); } } GUILayout.Label(typeGroup.Name); } SirenixEditorGUI.EndIndentedHorizontal(); if (toggleExpansion || (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))) { typeGroup.IsExpanded = !typeGroup.IsExpanded; Event.current.Use(); } } SirenixEditorGUI.EndListItem(); if (SirenixEditorGUI.BeginFadeGroup(typeGroup, typeGroup.IsExpanded || !searchText.IsNullOrWhitespace())) { EditorGUI.indentLevel++; foreach (var subType in typeGroup.SubTypes) { if (typeGroup.IsTypeVisible(subType.DrawnType)) { this.DrawType(subType, entry); } } foreach (var subGroup in typeGroup.SubGroups) { this.DrawTypeGroup(subGroup, entry, searchText); } EditorGUI.indentLevel--; } SirenixEditorGUI.EndFadeGroup(); }
/// <summary> /// Adds a menu item with the specified object instance and icon at the the specified path. /// </summary> /// <param name="path">The menu item path.</param> /// <param name="instance">The object instance.</param> /// <param name="icon">The icon.</param> public void Add(string path, object instance, EditorIcon icon) { this.AddObjectAtPath(path, instance).AddIcon(icon); }
private void OnGUI() { // Magic number. minSize = new Vector2(420f, 720f); titleContent = new GUIContent("Menu Items"); GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.richText = true; labelStyle.wordWrap = true; if (behaviorList == null || conditionList == null) { InitializeLists(); } EditorIcon logo = new EditorIcon("logo_creator"); Rect rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box); GUI.DrawTexture(rect, logo.Texture, ScaleMode.ScaleToFit); GUILayout.Space(20f); EditorGUILayout.HelpBox("This window provides editor configuration settings for the Innoactive Creator. " + "It is supposed to be changed only by a software developer. " + "Modification of these values may lead to various issues.", MessageType.Warning); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (isEditUnlocked == false) { if (GUILayout.Button("I understand the risks. Let me edit it.")) { isEditUnlocked = true; } } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.Space(20f); if (string.IsNullOrEmpty(EditorConfigurator.Instance.AllowedMenuItemsSettingsAssetPath)) { EditorGUILayout.LabelField("The property <i>AllowedMenuItemsSettingsAssetPath</i> of the current editor configuration returns <i>null</i> or an empty string. " + "For this reason, this feature is disabled.\n\n" + "If you want to configure what menu items should be displayed in the <i>Training Step Inspector</i>, " + "override the <i>DefaultEditorConfiguration</i> (if you have not already done so) " + "and let this property return a valid asset path.\n\n" + "Example of a valid asset path:\n<i>Assets/Editor/Innoactive/allowed_menu_items_config.json</i>\n\n" + "Note: The file will then be created at this location and is used to save the configurations made in this window.", labelStyle); return; } scrollPosition = GUILayout.BeginScrollView(scrollPosition, true, true); { EditorGUI.BeginDisabledGroup(isEditUnlocked == false); { EditorGUILayout.LabelField("<b>Here you can change whether a behavior or a condition menu item is selectable in the <i>Training Step Inspector</i></b>.\n\n" + "Non-editable entries are behavior or condition menu items that had been deleted from the project at some point.\n\n" + "<i>Available Behaviors:</i>\n", labelStyle); IDictionary <string, bool> behaviors = EditorConfigurator.Instance.AllowedMenuItemsSettings.SerializedBehaviorSelections; // ReSharper disable once PossibleNullReferenceException if (behaviorList.Count == 0) { EditorGUILayout.LabelField("<i>None</i>", labelStyle); } else { // ReSharper disable once PossibleNullReferenceException foreach (EntityEntry entry in behaviorList) { EditorGUI.BeginDisabledGroup(entry.IsTypeValid == false); { if (EditorGUILayout.ToggleLeft(entry.DisplayedName, behaviors[entry.AssemblyQualifiedName]) != behaviors[entry.AssemblyQualifiedName]) { // Toggle was clicked. behaviors[entry.AssemblyQualifiedName] = behaviors[entry.AssemblyQualifiedName] == false; AllowedMenuItemsSettings.Save(EditorConfigurator.Instance.AllowedMenuItemsSettings); } } EditorGUI.EndDisabledGroup(); } } EditorGUILayout.LabelField("\n<i>Available Conditions:</i>\n", labelStyle); IDictionary <string, bool> conditions = EditorConfigurator.Instance.AllowedMenuItemsSettings.SerializedConditionSelections; // ReSharper disable once PossibleNullReferenceException if (conditionList.Count == 0) { EditorGUILayout.LabelField("<i>None</i>", labelStyle); } else { // ReSharper disable once PossibleNullReferenceException foreach (EntityEntry entry in conditionList) { EditorGUI.BeginDisabledGroup(entry.IsTypeValid == false); { if (EditorGUILayout.ToggleLeft(entry.DisplayedName, conditions[entry.AssemblyQualifiedName]) != conditions[entry.AssemblyQualifiedName]) { // Toggle was clicked. conditions[entry.AssemblyQualifiedName] = conditions[entry.AssemblyQualifiedName] == false; AllowedMenuItemsSettings.Save(EditorConfigurator.Instance.AllowedMenuItemsSettings); } } EditorGUI.EndDisabledGroup(); } } } EditorGUI.EndDisabledGroup(); } GUILayout.EndScrollView(); }
private static extern SpriteTexture Internal_getEditorIcon(EditorIcon icon);
/// <summary> /// Constructor yay. /// </summary> /// <param name="icon">The icon to show.</param> public EditorIconAttribute(EditorIcon icon) { this.Icon = icon; }
/// <summary> /// Assigns the specified icon to all menu items in the collection. /// </summary> public static IEnumerable <OdinMenuItem> AddIcons(this IEnumerable <OdinMenuItem> menuItems, EditorIcon icon) { foreach (var item in menuItems) { item.Icon = icon.Highlighted; item.IconSelected = icon.Raw; } return(menuItems); }
public static Rect DrawIcon(EditorIcon icon, Vector2 pos, float scale = 1f, bool center = true) { return DrawIcon(icon, -1, pos, scale, center); }