internal static Texture GetIcon(IconInfo info) { Texture icon; if (_iconTextures.TryGetValue(info.key, out icon)) { return icon; } icon = AssetDatabase.LoadMainAssetAtPath(info.path) as Texture; if (icon != null) { _iconTextures[info.key] = icon; } return icon; }
public override void OnInspectorGUI() { ApexSettings settings; if (ApexSettings.TryGetSettings(out settings)) { var info = new IconInfo { key = "ApexPath", path = string.Concat(settings.relativeDataFolder, "/ApexPath.png") }; var icon = ProductManager.GetIcon(info); EditorGUILayout.LabelField(new GUIContent(" Apex Components", icon)); } else { EditorGUILayout.LabelField("Apex Components"); } EditorGUI.indentLevel++; var master = this.target as ApexComponentMaster; foreach (var category in master.componentCategories) { EditorGUILayout.BeginVertical("Box"); EditorGUILayout.GetControlRect(true, 16f, EditorStyles.foldout); Rect foldRect = GUILayoutUtility.GetLastRect(); category.isOpen = EditorGUI.Foldout(foldRect, category.isOpen, category.name, true); if (!category.isOpen) { EditorGUILayout.EndVertical(); continue; } foreach (ApexComponentMaster.ComponentInfo c in category) { var lblStyle = c.component.enabled ? EditorStyles.label : disabledLabel; var visible = EditorGUILayout.ToggleLeft(c.name, c.isVisible, lblStyle); if (visible != c.isVisible) { if (this.targets.Length > 1) { foreach (var t in this.targets) { ((ApexComponentMaster)t).Toggle(c.name, visible); } } else { master.Toggle(c); } EditorUtility.SetDirty(master); } } EditorGUILayout.EndVertical(); } EditorGUI.indentLevel--; if (GUILayout.Button("Toggle All")) { foreach (var t in this.targets) { var tmp = t as ApexComponentMaster; tmp.ToggleAll(); EditorUtility.SetDirty(tmp); } } }