protected override void OnContentGUI() { GUILayout.BeginVertical(Styles.background); GUILayout.Label(new GUIContent(changelog.plugin.manifest.name), Styles.plugin); LudiqGUI.Space(2); GUILayout.Label(new GUIContent($"Version {changelog.version}"), Styles.version); if (!StringUtility.IsNullOrWhiteSpace(changelog.description)) { LudiqGUI.Space(5); GUILayout.Label(new GUIContent(changelog.description.Trim()), Styles.description); } foreach (var change in changes) { LudiqGUI.Space(10); GUILayout.BeginHorizontal(GUILayout.ExpandHeight(false)); GUILayout.Label(GUIContent.none, Styles.bullet); GUILayout.Label(change.type, Styles.changeType); GUILayout.Label(change.content, Styles.changeContent); LudiqGUI.EndHorizontal(); } LudiqGUI.EndVertical(); }
public static string Title(IGraphNester nester) { var graph = nester.childGraph; if (!StringUtility.IsNullOrWhiteSpace(graph?.title)) { return(graph?.title); } if (nester.nest.source == GraphSource.Macro && (UnityObject)nester.nest.macro != null) { var macroName = ((UnityObject)nester.nest.macro).name; if (BoltCore.Configuration.humanNaming) { return(macroName.Prettify()); } else { return(macroName); } } return(nester.GetType().HumanName()); }
public override string Title() { var graph = transition.nest.graph; if (graph != null) { if (!StringUtility.IsNullOrWhiteSpace(graph.title)) { return(graph.title); } using (var recursion = Recursion.New(1)) { var events = graph.GetUnitsRecursive(recursion).OfType <IEventUnit>().ToList(); if (events.Count == 0) { return("(No Event)"); } else if (events.Count == 1) { return(events[0].Description().title); } else // if (events.Count > 1) { return("(Multiple Events)"); } } } else { return("(No Transition)"); } }
public override string Summary() { var graph = transition.nest.graph; if (graph != null) { if (!StringUtility.IsNullOrWhiteSpace(graph.summary)) { return(graph.summary); } using (var recursion = Recursion.New(1)) { var events = graph.GetUnitsRecursive(recursion).OfType <IEventUnit>().ToList(); if (events.Count == 0) { return("Open the transition graph to add an event."); } else if (events.Count == 1) { return(events[0].Description().summary); } else // if (events.Count > 1) { return("Open the transition graph to see the full transition."); } } } else { return("Choose a source in the graph inspector."); } }
public void OnNameGUI(Rect namePosition) { namePosition = BeginLabeledBlock(nameMetadata, namePosition); var newName = EditorGUI.DelayedTextField(namePosition, (string)nameMetadata.value); if (EndBlock(nameMetadata)) { var variableDeclarations = (VariableDeclarationCollection)metadata.parent.value; if (StringUtility.IsNullOrWhiteSpace(newName)) { EditorUtility.DisplayDialog("Edit Variable Name", "Please enter a variable name.", "OK"); return; } else if (variableDeclarations.Contains(newName)) { EditorUtility.DisplayDialog("Edit Variable Name", "A variable with the same name already exists.", "OK"); return; } nameMetadata.RecordUndo(); variableDeclarations.EditorRename((VariableDeclaration)metadata.value, newName); nameMetadata.value = newName; } }
protected override string DefinedSurtitle() { var hasCurrentTitle = !StringUtility.IsNullOrWhiteSpace(unit.nest.graph?.title); var hasMacroTitle = unit.nest.source == GraphSource.Macro && (UnityObject)unit.nest.macro != null; return(hasCurrentTitle || hasMacroTitle ? BoltFlowNameUtility.UnitTitle(unitType, false, false) : null); }
public IEnumerable <string> GetDynamicVariableNames(VariableKind kind, GraphReference reference) { return(units.OfType <IUnifiedVariableUnit>() .Where(v => v.kind == kind && Flow.CanPredict(v.name, reference)) .Select(v => Flow.Predict <string>(v.name, reference)) .Where(name => !StringUtility.IsNullOrWhiteSpace(name)) .Distinct() .OrderBy(name => name)); }
protected override void OnContentGUI() { GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true)); LudiqGUI.FlexibleSpace(); EditorGUILayout.LabelField($"Version {aboutable.version}", LudiqStyles.centeredLabel); LudiqGUI.FlexibleSpace(); if (!StringUtility.IsNullOrWhiteSpace(aboutable.description)) { EditorGUILayout.LabelField(aboutable.description.Trim(), LudiqStyles.centeredLabel); } LudiqGUI.FlexibleSpace(); if (!StringUtility.IsNullOrWhiteSpace(aboutable.author)) { EditorGUILayout.LabelField($"{aboutable.authorLabel.Trim()} {aboutable.author.Trim()}", LudiqStyles.centeredLabel); } if (!StringUtility.IsNullOrWhiteSpace(aboutable.copyrightHolder)) { EditorGUILayout.LabelField($"Copyright \u00a9 {aboutable.copyrightYear} {aboutable.copyrightHolder.Trim()}. All Rights Reserved.", LudiqStyles.centeredLabel); } if (aboutable.authorLogo != null) { LudiqGUI.FlexibleSpace(); LudiqGUI.BeginHorizontal(); LudiqGUI.FlexibleSpace(); var logoHeight = Styles.authorLogoHeight; var logoWidth = (float)aboutable.authorLogo.width / aboutable.authorLogo.height * logoHeight; var logoPosition = GUILayoutUtility.GetRect(logoWidth, logoHeight); if (!string.IsNullOrEmpty(aboutable.authorUrl)) { if (GUI.Button(logoPosition, aboutable.authorLogo, GUIStyle.none)) { Process.Start(aboutable.authorUrl); } } else if (e.type == EventType.Repaint) { GUI.DrawTexture(logoPosition, aboutable.authorLogo); } LudiqGUI.FlexibleSpace(); LudiqGUI.EndHorizontal(); } LudiqGUI.FlexibleSpace(); LudiqGUI.EndVertical(); }
public static IEnumerable <string> GetPredefinedVariableNames(VariableKind kind, GraphReference reference) { VariableDeclarations source = null; switch (kind) { case VariableKind.Flow: break; case VariableKind.Graph: { source = Variables.Graph(reference); break; } case VariableKind.Object: { if (reference.gameObject != null) { source = Variables.Object(reference.gameObject); } break; } case VariableKind.Scene: { if (reference.scene != null && Variables.ExistInScene(reference.scene)) { source = Variables.Scene(reference.scene); } break; } case VariableKind.Application: { source = Variables.Application; break; } case VariableKind.Saved: { source = Variables.Saved; break; } default: throw new UnexpectedEnumValueException <VariableKind>(kind); } if (source == null) { return(Enumerable.Empty <string>()); } return(source.Select(d => d.name).Where(name => !StringUtility.IsNullOrWhiteSpace(name)).OrderBy(name => name)); }
public static string Summary(IGraphNester nester) { var graph = nester.childGraph; if (!StringUtility.IsNullOrWhiteSpace(graph?.summary)) { return(graph?.summary); } return(nester.GetType().Summary()); }
public static Warning InvalidWarning(IUnitPortDefinition definition) { if (!StringUtility.IsNullOrWhiteSpace(definition.label)) { return(Warning.Caution($"{definition.GetType().HumanName().ToLower().FirstCharacterToUpper()} '{definition.label}' is not properly configured and is currently ignored.")); } else { return(Warning.Caution($"A {definition.GetType().HumanName().ToLower()} with incomplete configuration is currently ignored.")); } }
public override string ToString() { if (StringUtility.IsNullOrWhiteSpace(label)) { return($"{major}.{minor}.{patch}"); } else { return($"{major}.{minor}.{patch}{label}{increment}"); } }
protected override void OnContentGUI() { GUILayout.BeginVertical(Styles.background); GUILayout.Label(acknowledgement.title, Styles.title); var hasAuthor = !StringUtility.IsNullOrWhiteSpace(acknowledgement.author); var hasCopyright = acknowledgement.copyrightYear != null; if (hasAuthor && hasCopyright) { GUILayout.Label($"Copyright \u00a9 {acknowledgement.copyrightYear} {acknowledgement.author}", Styles.property); } else if (hasAuthor) { GUILayout.Label($"Author: {acknowledgement.author}", Styles.property); } else if (hasCopyright) { GUILayout.Label($"Copyright \u00a9 {acknowledgement.copyrightYear}", Styles.property); } if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.url)) { if (GUILayout.Button(acknowledgement.url, Styles.url)) { Process.Start(acknowledgement.url); } } if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.licenseName)) { GUILayout.Label("License: " + acknowledgement.licenseName.Trim(), Styles.property); } LudiqGUI.EndVertical(); if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.licenseText)) { GUILayout.Box(GUIContent.none, LudiqStyles.horizontalSeparator); licenseScroll = GUILayout.BeginScrollView(licenseScroll, Styles.licenseBackground); GUILayout.Label(licenseText, Styles.licenseText); GUILayout.EndScrollView(); LudiqGUI.Space(-1); } }
protected override string DefinedSurtitle() { var hasCurrentTitle = !StringUtility.IsNullOrWhiteSpace(unit.nest.graph?.title); var hasMacroTitle = unit.nest.source == GraphSource.Macro && (UnityObject)unit.nest.macro != null; if (hasCurrentTitle || hasMacroTitle) { return(unit.GetType().HumanName()); } else { return(null); } }
private void OnPortGUI(Rect portPosition, IUnitPort port) { var portDescription = port.Description <UnitPortDescription>(); var labelWidth = portPosition.width - Styles.portIcon.fixedWidth - Styles.portIcon.margin.right; var iconPosition = new Rect ( portPosition.x, portPosition.y, Styles.portIcon.fixedWidth, Styles.portIcon.fixedHeight ); var icon = portDescription.icon?[IconSize.Small]; if (icon != null) { GUI.DrawTexture(iconPosition, icon); } var labelContent = GetLabelContent(port); var labelPosition = new Rect ( iconPosition.xMax + Styles.portIcon.margin.right, portPosition.y, labelWidth, Styles.portLabel.CalcHeight(labelContent, labelWidth) ); GUI.Label(labelPosition, labelContent, Styles.portLabel); var summary = portDescription.summary; if (!StringUtility.IsNullOrWhiteSpace(summary)) { var descriptionContent = new GUIContent(summary); var descriptionPosition = new Rect ( labelPosition.x, labelPosition.yMax, labelWidth, Styles.portDescription.CalcHeight(descriptionContent, labelWidth) ); GUI.Label(descriptionPosition, descriptionContent, Styles.portDescription); } }
public void IsNotNullOrWhiteSpace(string value) { if (!Ensure.IsActive) { return; } IsNotNull(value); if (StringUtility.IsNullOrWhiteSpace(value)) { throw new ArgumentException(ExceptionMessages.Strings_IsNotNullOrWhiteSpace_Failed, paramName); } }
protected override bool CanAdd() { if (StringUtility.IsNullOrWhiteSpace(parentInspector.newName)) { parentInspector.highlightPlaceholder = true; EditorUtility.DisplayDialog("New Variable", "Please enter a variable name.", "OK"); return(false); } else if (((VariableDeclarations)parentInspector.metadata.value).IsDefined(parentInspector.newName)) { parentInspector.highlightNewNameField = true; EditorUtility.DisplayDialog("New Variable", "A variable with the same name already exists.", "OK"); return(false); } return(true); }
public static string Title(IGraphNester nester, string defaultName) { var graph = nester.childGraph; if (!StringUtility.IsNullOrWhiteSpace(graph?.title)) { return(graph?.title); } if (nester.nest.source == GraphSource.Macro && (UnityObject)nester.nest.macro != null) { var macroName = ((UnityObject)nester.nest.macro).name; return(BoltCore.Configuration.humanNaming ? macroName.Prettify() : macroName); } return(!string.IsNullOrEmpty(defaultName) ? defaultName : nester.GetType().HumanName()); }
public static float HeightWithLabel(Metadata metadata, float width, float height, GUIContent label = null, GUIStyle labelStyle = null) { label = ProcessLabel(metadata, label); if (label == GUIContent.none) { return(height); } var labelWidth = LabelWidth(metadata, width); labelStyle = ProcessLabelStyle(metadata, labelStyle); var wide = metadata.HasAttribute <InspectorWideAttribute>(); var labelHeight = labelStyle.CalcHeight(label, labelWidth); if (expandTooltip.value || metadata.HasAttribute <InspectorExpandTooltipAttribute>()) { var tooltipHeight = StringUtility.IsNullOrWhiteSpace(label.tooltip) ? 0 : LudiqStyles.expandedTooltip.CalcHeight(new GUIContent(label.tooltip), labelWidth); if (wide) { height += labelHeight + tooltipHeight; } else { height = Mathf.Max(height, labelHeight + tooltipHeight); } } else { if (wide) { height += labelHeight; } else { height = Mathf.Max(height, labelHeight); } } return(height); }
public float GetFooterHeight(float width) { var hasSummary = !StringUtility.IsNullOrWhiteSpace(summary); var hasIcon = icon != null; var hasPorts = footerPorts.Any(); var height = 0f; width -= 2 * FooterStyles.padding; height += FooterStyles.padding; if (hasSummary) { if (hasIcon) { height += Mathf.Max(FooterStyles.unitIconSize, GetFooterSummaryHeight(width - FooterStyles.unitIconSize - FooterStyles.spaceAfterUnitIcon)); } else { height += GetFooterSummaryHeight(width); } } if (hasSummary && hasPorts) { height += FooterStyles.spaceBetweenDescriptionAndPorts; } foreach (var port in footerPorts) { height += GetFooterPortHeight(width, port); height += FooterStyles.spaceBetweenPorts; } if (hasPorts) { height -= FooterStyles.spaceBetweenPorts; } height += FooterStyles.padding; return(height); }
private float GetPortHeight(float paddedWidth, IUnitPort port) { var portDescription = port.Description <UnitPortDescription>(); var labelWidth = paddedWidth - Styles.portIcon.fixedWidth - Styles.portIcon.margin.right; var height = 0f; height += Styles.portLabel.CalcHeight(GetLabelContent(port), labelWidth); var summary = portDescription.summary; if (!StringUtility.IsNullOrWhiteSpace(summary)) { height += Styles.portDescription.CalcHeight(new GUIContent(summary), labelWidth); } return(height); }
private string GetFooterPortLabel(IUnitPort port) { string type; if (port is ValueInput) { type = ((IUnitValuePort)port).type.DisplayName() + " Input"; } else if (port is ValueOutput) { type = ((IUnitValuePort)port).type.DisplayName() + " Output"; } else if (port is ControlInput) { type = "Trigger Input"; } else if (port is ControlOutput) { type = "Trigger Output"; } else { throw new NotSupportedException(); } var portDescription = PortDescription(port); if (!StringUtility.IsNullOrWhiteSpace(portDescription.summary)) { return($"<b>{portDescription.label}:</b> {portDescription.summary} {LudiqGUIUtility.DimString($"({type})")}"); } else { return($"<b>{portDescription.label}:</b> {LudiqGUIUtility.DimString($"({type})")}"); } }
public static void GenerateLicenseFile(string path) { var acknowledgements = PluginContainer.plugins .SelectMany(plugin => plugin.resources.acknowledgements) .Distinct() .ToArray(); var sb = new StringBuilder(); sb.AppendLine("The Unity Asset Store policy requires that all third-party"); sb.AppendLine("licenses be contained in a single LICENSES files."); sb.AppendLine("This file is auto-generated for this purpose."); sb.AppendLine(); sb.AppendLine("However, you can find a more readable version of each product's"); sb.AppendLine("acknowledgements in its About window, found in the Tools menu."); sb.AppendLine(); sb.AppendLine("Acknowledgements below:"); foreach (var acknowledgement in acknowledgements) { sb.AppendLine(" - " + acknowledgement.title); } foreach (var acknowledgement in acknowledgements) { sb.AppendLine(); sb.AppendLine("============================="); sb.AppendLine(); sb.AppendLine(acknowledgement.title); var hasAuthor = !StringUtility.IsNullOrWhiteSpace(acknowledgement.author); var hasCopyright = acknowledgement.copyrightYear != null; if (hasAuthor && hasCopyright) { sb.AppendLine($"Copyright \u00a9 {acknowledgement.copyrightYear} {acknowledgement.author}"); } else if (hasAuthor) { sb.AppendLine($"Author: {acknowledgement.author}"); } else if (hasCopyright) { sb.AppendLine($"Copyright \u00a9 {acknowledgement.copyrightYear}"); } if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.url)) { sb.AppendLine(acknowledgement.url); } if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.licenseName)) { sb.AppendLine("License: " + acknowledgement.licenseName.Trim()); } if (!StringUtility.IsNullOrWhiteSpace(acknowledgement.licenseText)) { var licenseText = string.Join("\n\n", acknowledgement.licenseText.Split(new[] { "\r\n\r\n", "\n\n" }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Replace("\r\n", "").Replace("\n", "")).ToArray()); sb.AppendLine(); sb.AppendLine(licenseText); } } if (path == null) { path = EditorUtility.SaveFilePanelInProject("License File", "LICENSES", "txt", null); } if (path != null) { File.WriteAllText(path, sb.ToString()); AssetDatabase.Refresh(); } }
public void OnFooterGUI(Rect position) { var hasSummary = !StringUtility.IsNullOrWhiteSpace(summary); var hasIcon = icon != null; var hasPorts = footerPorts.Any(); var y = position.y; y += FooterStyles.padding; position.x += FooterStyles.padding; position.width -= FooterStyles.padding * 2; if (hasSummary) { if (hasIcon) { var iconPosition = new Rect ( position.x, y, FooterStyles.unitIconSize, FooterStyles.unitIconSize ); var summaryWidth = position.width - iconPosition.width - FooterStyles.spaceAfterUnitIcon; var summaryPosition = new Rect ( iconPosition.xMax + FooterStyles.spaceAfterUnitIcon, y, summaryWidth, GetFooterSummaryHeight(summaryWidth) ); GUI.DrawTexture(iconPosition, icon?[FooterStyles.unitIconSize]); OnFooterSummaryGUI(summaryPosition); y = Mathf.Max(iconPosition.yMax, summaryPosition.yMax); } else { OnFooterSummaryGUI(position.VerticalSection(ref y, GetFooterSummaryHeight(position.width))); } } if (hasSummary && hasPorts) { y += FooterStyles.spaceBetweenDescriptionAndPorts; } foreach (var port in footerPorts) { OnFooterPortGUI(position.VerticalSection(ref y, GetFooterPortHeight(position.width, port)), port); y += FooterStyles.spaceBetweenPorts; } if (hasPorts) { y -= FooterStyles.spaceBetweenPorts; } y += FooterStyles.padding; }