private void RefreshSketchList() { _sketches.Clear(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { var assemblyName = assembly.GetName().Name; if (!assemblyName.EndsWith(".Sketches")) { continue; } var fixtures = new List <SketchFixture>(); foreach (var type in assembly.GetTypes()) { if (type.IsAbstract) { continue; } var sketchFixtureAttribute = (SketchFixtureAttribute)Attribute .GetCustomAttribute(type, typeof(SketchFixtureAttribute)); if (sketchFixtureAttribute == null) { continue; } var descriptionAttribute = (SketchDescriptionAttribute)Attribute .GetCustomAttribute(type, typeof(SketchDescriptionAttribute)); var description = descriptionAttribute?.Description; var name = type.FullName; var sketchFixture = new SketchFixture(name, type, description); fixtures.Add(sketchFixture); } _sketches.Add(new SketchAssembly(assembly.GetName().Name, fixtures.ToArray())); } }
private void DrawSketchRunnerGUIItem(SketchFixture sketchFixture) { GUILayout.BeginHorizontal(); var nameGUISkin = EditorStyles.boldLabel; var nameGUICon = new GUIContent(sketchFixture.FullName); var descGUISkin = EditorStyles.miniLabel; var descGUICon = new GUIContent(sketchFixture.Description); var nameTextHeight = nameGUISkin.CalcHeight(nameGUICon, Screen.width - BUTTON_WIDTH); var descriptionTextHeight = descGUISkin.CalcHeight(descGUICon, Screen.width - BUTTON_WIDTH); var textHeight = nameTextHeight + descriptionTextHeight; var buttonHeight = GUILayout.Height(textHeight); var runButtonWidth = GUILayout.Width(textHeight * 1.4f); var playIconContent = new GUIContent(_playIcon); var runSketch = GUILayout.Button(playIconContent, buttonHeight, runButtonWidth); if (runSketch) { _selectedSketch = sketchFixture.TypeInfo; } var openButtonWidth = GUILayout.Width(textHeight); var editIconContent = new GUIContent(_editIcon); var openCode = GUILayout.Button(editIconContent, buttonHeight, openButtonWidth); if (openCode) { SketchAssetOpener.OpenSketch(sketchFixture.TypeInfo); } GUILayout.BeginVertical(); GUILayout.Label(nameGUICon, nameGUISkin); GUILayout.Label(descGUICon, descGUISkin); GUILayout.EndVertical(); var pinButtonSkin = new GUIStyle(GUI.skin.label); if (PinnedSketchTracker.IsPinned(sketchFixture.FullName)) { var unpinnedIconContent = new GUIContent(_pinnedIcon); var unpinClicked = GUILayout.Button(unpinnedIconContent, pinButtonSkin, buttonHeight, openButtonWidth); if (unpinClicked) { PinnedSketchTracker.UnpinSketch(sketchFixture.FullName); } } else { var pinnedIconContent = new GUIContent(_unpinnedIcon); var pinClicked = GUILayout.Button(pinnedIconContent, pinButtonSkin, buttonHeight, openButtonWidth); if (pinClicked) { PinnedSketchTracker.PinSketch(sketchFixture.FullName); } } GUILayout.EndHorizontal(); }