// ====================================================================== // Initialization/Teardown // ---------------------------------------------------------------------- public void OnEnable() { Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); titleContent = new GUIContent("About iCanScript", iCanScriptLogo); }
// ====================================================================== // Initialization // ---------------------------------------------------------------------- // Prepares the editor for editing a graph. Note that the graph to edit // is not configured at this point. We must wait for an activate from // the graph inspector to know which graph to edit. public new void OnEnable() { base.OnEnable(); // -- Set window title -- Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); titleContent = new GUIContent("Visual Editor", iCanScriptLogo); // Tell Unity we want to be informed of move drag events wantsMouseMove = true; // Create worker objects. myGraphics = new iCS_Graphics(); myContextualMenu = new iCS_ContextualMenu(); // Get snapshot for realtime clock. myCurrentTime = Time.realtimeSinceStartup; // Update visual editor cache. UpdateVisualEditorCache(); // Register for window under mouse change SystemEvents.OnWindowUnderMouseChange += helpWindowChange; // -- Initialize Sub-Systems -- QueueOnGUICommand(WorkflowAssistantInit); QueueOnGUICommand(HelpInit); }
// =================================================================== // BUILDER // ------------------------------------------------------------------- /// Creates a port editor window at the given screen position. /// /// @param screenPosition The screen position where the editor /// should be displayed. /// public static EditorWindow Create(iCS_EditorObject node, Vector2 screenPosition) { if (node == null) { return(null); } if (node.IsEventHandler) { return(EventHandlerEditor.Create(node, screenPosition)); } if (node.IsFunctionDefinition) { return(FunctionDefinitionEditor.Create(node, screenPosition)); } if (node.IsInstanceNode) { return(PropertyEditor.Create(node, screenPosition)); } if (node.IsInlineCode) { return(InlineCodeEditor.Create(node, screenPosition)); } var self = NodeEditor.CreateInstance <NodeEditor>(); self.vsObject = node; Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); self.titleContent = new GUIContent("Node Editor", iCanScriptLogo); self.ShowUtility(); return(self); }
// ---------------------------------------------------------------------- public static string Search(ref Rect toolbarRect, float width, string value, float leftMargin, float rightMargin, bool isRightJustified= false) { Rect r= ReserveArea(ref toolbarRect, width, leftMargin, rightMargin, isRightJustified); float iconSize= GetHeight(); if(r.width < iconSize+1f) return value; r.y+= 2f; r.width-= iconSize; Texture2D searchIcon= null; if(TextureCache.GetTexture(iCS_EditorStrings.SearchIcon, out searchIcon)) { GUI.DrawTexture(new Rect(r.xMin-searchIcon.width, r.y-1f, searchIcon.width, searchIcon.height), searchIcon); } else { Debug.LogWarning("iCanScript: Cannot find search Icon in resource folder !!!"); } Texture2D cancelIcon= null; if(TextureCache.GetTexture(iCS_EditorStrings.CancelIcon, out cancelIcon)) { Rect cancelRect= new Rect(r.xMax, r.y-1f, cancelIcon.width, cancelIcon.height); GUI.DrawTexture(cancelRect, cancelIcon); // Clear the search if the cancel icon is depressed. var ev= Event.current; if(ev != null && ev.isMouse) { if(cancelRect.Contains(ev.mousePosition)) { return ""; } } } else { Debug.LogWarning("iCanScript: Cannot find cancel Icon in resource folder !!!"); } return GUI.TextField(r, value, EditorStyles.toolbarTextField); }
public new void OnEnable() { base.OnEnable(); // -- Set window title -- Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); titleContent = new GUIContent("Tree View", iCanScriptLogo); }
// ================================================================================= // Activation/Deactivation. // --------------------------------------------------------------------------------- public new void OnEnable() { base.OnEnable(); Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); titleContent = new GUIContent(GetTitle(), iCanScriptLogo); optionStrings = GetMainSelectionGridStrings(); minSize = new Vector2(500f, 400f); maxSize = new Vector2(500f, 400f); }
// --------------------------------------------------------------------------------- /// Assure a minimum size for the library window. public new void OnEnable() { base.OnEnable(); // -- Set window title -- Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); titleContent = new GUIContent("Library", iCanScriptLogo); // -- Set minimum size for window -- minSize = new Vector2(270f, 270f); }
// ================================================================================= // Activation/Deactivation. // --------------------------------------------------------------------------------- public static new EditorWindow Create(iCS_EditorObject node, Vector2 screenPosition) { // Get existing open window or if none, make a new one: var self = PropertyEditor.CreateInstance <PropertyEditor>(); self.vsObject = node; Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); self.titleContent = new GUIContent("Property Editor", iCanScriptLogo); self.ShowUtility(); return(self); }
// ================================================================================= /// Initialize all class variables. static void Initialize() { // -- Initialize only once. -- if (isInitialized) { return; } isInitialized = true; // -- Build the window area shapes. -- ourHeaderShape = Shapes.Rectangle2D(0, 0, kWidth, kHeaderHeight); ourListAreaShape = Shapes.Rectangle2D(0, kHeaderHeight, kWidth, kListAreaHeight); // -- Load adornments. -- TextureCache.GetTexture(iCS_EditorStrings.LogoIcon, out ourLogo); ourLogoPosition = new Rect(kWidth - 80f, 16f, 64f, 64f); // -- Setup GUI styles. -- ourHeaderTextStyle = new GUIStyle(EditorStyles.largeLabel); ourHeaderTextStyle.fontSize = kHeaderFontSize; ourHeaderTextStyle.fontStyle = FontStyle.Normal; ourProjectsText = new GUIContent("Packages"); var projectsTextSize = ourHeaderTextStyle.CalcSize(ourProjectsText); ourProjectsTextRect = new Rect(kSpacer, kHeaderHeight - kSpacer - projectsTextSize.y, projectsTextSize.x, projectsTextSize.y); ourCreatePackageText = new GUIContent("Create Package"); projectsTextSize = ourHeaderTextStyle.CalcSize(ourCreatePackageText); ourCreatePackageTextRect = new Rect(kSpacer, kHeaderHeight - kSpacer - projectsTextSize.y, projectsTextSize.x, projectsTextSize.y); ourProjectTitleStyle = new GUIStyle(EditorStyles.largeLabel); ourProjectTitleStyle.fontSize = kTitleFontSize; ourProjectFolderStyle = new GUIStyle(EditorStyles.largeLabel); ourProjectFolderStyle.fontSize = kFolderFontSize; ourTitleHeight = ourProjectTitleStyle.CalcSize(new GUIContent("A")).y; ourNewProjectText = new GUIContent("+ New Package"); var newProjectTextSize = ourProjectTitleStyle.CalcSize(ourNewProjectText); ourNewProjectTextRect = new Rect(ourLogoPosition.x - kSpacer - newProjectTextSize.x, kHeaderHeight - 1.5f * kSpacer - newProjectTextSize.y, newProjectTextSize.x, newProjectTextSize.y); ourTextFieldStyle = new GUIStyle(EditorStyles.textField); ourTextFieldStyle.fontSize = kTitleFontSize; ourPopupStyle = new GUIStyle(EditorStyles.popup); ourPopupStyle.fontSize = kTitleFontSize; // -- Refresh existing project information. -- PackageController.UpdatePackageDatabase(); }
// =================================================================== // BUILDER // ------------------------------------------------------------------- /// Creates a port editor window at the given screen position. /// /// @param screenPosition The screen position where the editor /// should be displayed. /// public static new EditorWindow Create(iCS_EditorObject port, Vector2 screenPosition) { if (port == null) { return(null); } var self = EventHandlerPortEditor.CreateInstance <EventHandlerPortEditor>(); self.vsObject = port; Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); self.titleContent = new GUIContent("Event Handler Port Editor", iCanScriptLogo); self.ShowUtility(); return(self); }
// =================================================================== // BUILDER // ------------------------------------------------------------------- /// Creates a port editor window at the given screen position. /// /// @param screenPosition The screen position where the editor /// should be displayed. /// public static new EditorWindow Create(iCS_EditorObject node, Vector2 screenPosition) { if (node == null) { return(null); } var self = FunctionDefinitionEditor.CreateInstance <FunctionDefinitionEditor>(); self.vsObject = node; Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); self.titleContent = new GUIContent("Function Definition Editor", iCanScriptLogo); self.ShowUtility(); return(self); }
int myParentSelection = 0; //< The parent package selection // ================================================================================= /// Creates a package selection window. public static PackageSelectionWindow Init() { // -- Create window. -- var editor = EditorWindow.CreateInstance <PackageSelectionWindow>(); editor.wantsMouseMove = true; // -- Set window title -- Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); editor.titleContent = new GUIContent("iCanScript Package Selection", iCanScriptLogo); // -- Fix window size. -- editor.minSize = new Vector2(kWidth, kHeaderHeight + kListAreaHeight); editor.maxSize = new Vector2(kWidth, kHeaderHeight + kListAreaHeight); // -- Show the window. -- editor.ShowUtility(); return(editor); }
// =================================================================== // BUILDER // ------------------------------------------------------------------- /// Creates a port editor window at the given screen position. /// /// @param screenPosition The screen position where the editor /// should be displayed. /// public static EditorWindow Create(iCS_EditorObject port, Vector2 screenPosition) { if (port == null) { return(null); } // Create the specific port editors. var parent = port.ParentNode; if (parent.IsEventHandler) { return(EventHandlerPortEditor.Create(port, screenPosition)); } if (parent.IsFunctionDefinition) { return(FunctionDefinitionPortEditor.Create(port, screenPosition)); } if (parent.IsPackage) { return(PackagePortEditor.Create(port, screenPosition)); } if (parent.IsKindOfFunction) { return(FunctionCallPortEditor.Create(port, screenPosition)); } // Create a generic port editor. var self = PortEditor.CreateInstance <PortEditor>(); self.vsObject = port; Texture2D iCanScriptLogo = null; TextureCache.GetTexture(iCS_EditorStrings.TitleLogoIcon, out iCanScriptLogo); self.titleContent = new GUIContent("Port Editor", iCanScriptLogo); self.ShowUtility(); return(self); }
// ================================================================================= // MAIN WINDOW // --------------------------------------------------------------------------------- public new void OnGUI() { // Draw common stuff for all editors base.OnGUI(); // Reset GUI alpha. GUI.color = Color.white; // Build GUI styles (in case they were changed by user). RebuildStyles(); // Outline column 1 area Rect column1Rect = new Rect(0, -1, kColumn1Width, position.height + 1); GUI.Box(column1Rect, ""); // Show selection grid. float lineHeight = selectionStyle.fixedHeight; float gridHeight = lineHeight * optionStrings.Length; selGridId = GUI.SelectionGrid(new Rect(0, kTitleHeight, kColumn1Width, gridHeight), selGridId, optionStrings, 1, selectionStyle); // Show title if (selGridId >= 0 && selGridId < optionStrings.Length) { string title = optionStrings[selGridId]; GUI.Label(new Rect(kColumn2X + 1.5f * kMargin, kMargin, kColumn2Width + kColumn3Width, kTitleHeight), title, titleStyle); } // Execute option specific panel. GUI.skin.label.richText = true; ProcessSelection(selGridId); // Show iCanScript version information. string version = iCS_EditorConfig.VersionStr; GUIContent versionContent = new GUIContent(version); Vector2 versionSize = GUI.skin.label.CalcSize(versionContent); float x = column1Rect.x + 0.5f * (column1Rect.width - versionSize.x); float y = column1Rect.yMax - 2.5f * versionSize.y; Rect pos = new Rect(x, y, versionSize.x, versionSize.y); GUI.Label(pos, versionContent); pos.y += versionSize.y; string buildDate = BuildInfo.kBuildDateStr; GUIContent buildDateContent = new GUIContent(buildDate); Vector2 buildDateSize = GUI.skin.label.CalcSize(buildDateContent); pos.x = column1Rect.x + 0.5f * (column1Rect.width - buildDateSize.x); pos.width = buildDateSize.x; pos.height = buildDateSize.y; GUI.Label(pos, buildDateContent); // Show product icon var logoWidth = 64f; var logoHeight = 64f; Texture2D iCanScriptLogo = null; if (TextureCache.GetTexture(iCS_EditorStrings.LogoIcon, out iCanScriptLogo)) { Rect r = new Rect(0.5f * (kColumn1Width - logoWidth), position.height - logoHeight - 10f - 2f * versionSize.y, logoWidth, logoHeight); GUI.DrawTexture(r, iCanScriptLogo); } }
// ====================================================================== // GUI Update // ---------------------------------------------------------------------- public void OnGUI() { // Init. if (h1 == null) { BuildStyles(); } // Show product icon var logoWidth = 64f; var logoHeight = 64f; Texture2D iCanScriptLogo = null; if (TextureCache.GetTexture(iCS_EditorStrings.LogoIcon, out iCanScriptLogo)) { Rect r = new Rect(kSpacer, kSpacer, logoWidth, logoHeight); GUI.DrawTexture(r, iCanScriptLogo); } // Show product name GUIContent title = new GUIContent("iCanScript"); var titleSize = h1.CalcSize(title); Rect rTitle = new Rect(2f * kSpacer + logoWidth, kSpacer, titleSize.x, titleSize.y); GUI.Label(rTitle, title, h1); // Show version GUIContent versionContent = new GUIContent(iCS_EditorConfig.VersionStr); Vector2 versionSize = GUI.skin.label.CalcSize(versionContent); Rect rVersion = new Rect(2f * kSpacer + logoWidth, rTitle.yMax, versionSize.x, versionSize.y); GUI.Label(rVersion, versionContent); // Column info float column1X = kSpacer; var editionTitle = new GUIContent("Edition: "); var buildDateTitle = new GUIContent("Build Date: "); var userLicenseTitle = new GUIContent("User License: "); var buildDateTitleSize = GUI.skin.label.CalcSize(buildDateTitle); var userLicenseTitleSize = GUI.skin.label.CalcSize(userLicenseTitle); float column1Width = Math3D.Max(buildDateTitleSize.x, userLicenseTitleSize.x); var labelHeight = buildDateTitleSize.y; float column2X = column1X + column1Width + kSpacer; float column2Width = position.width - column2X - kSpacer; // Edition var rEdition = new Rect(column1X, kSpacer + logoHeight + labelHeight, column2Width, labelHeight); GUI.Label(rEdition, editionTitle); rEdition.x = column2X; rEdition.width = column2Width; GUI.Label(rEdition, EditionController.ToString()); // User License var rUserLicense = new Rect(column1X, rEdition.yMax, column1Width, labelHeight); GUI.Label(rUserLicense, userLicenseTitle); var userLicense = LicenseController.LicenseAsString(); if (string.IsNullOrEmpty(userLicense)) { userLicense = "None"; } var userLicenseSize = GUI.skin.label.CalcSize(new GUIContent(userLicense)); rUserLicense.x = column2X; rUserLicense.width = column2Width; GUI.Label(rUserLicense, userLicense); // Build date var rBuildDate = new Rect(column1X, rUserLicense.yMax, column2Width, labelHeight); GUI.Label(rBuildDate, buildDateTitle); GUIContent buildDate = new GUIContent(BuildInfo.kBuildDateStr); rBuildDate.x = column2X; rBuildDate.width = column2Width; GUI.Label(rBuildDate, buildDate); // Disclamer GUIContent copyright = new GUIContent("(c) copyright LogikEdge 2021. All rights reserved."); var copyrightSize = GUI.skin.label.CalcSize(copyright); var rCopyright = new Rect(column1X, rBuildDate.yMax + copyrightSize.y, copyrightSize.x, copyrightSize.y); GUI.Label(rCopyright, copyright); var p = position; p.width = Math3D.Max(copyrightSize.x + 2f * kSpacer, column2X + userLicenseSize.x + kSpacer); p.height = rCopyright.yMax + kSpacer; position = p; }