static Styles() { // Disabling word wrap because Unity's CalcSize and CalcHeight // are broken w.r.t. pixel-perfection and matrix title = new GUIStyle(BoltCore.Styles.nodeLabel); title.padding = new RectOffset(0, 5, 0, 2); title.margin = new RectOffset(0, 0, 0, 0); title.fontSize = 12; title.alignment = TextAnchor.MiddleLeft; title.wordWrap = false; surtitle = new GUIStyle(BoltCore.Styles.nodeLabel); surtitle.padding = new RectOffset(0, 5, 0, 0); surtitle.margin = new RectOffset(0, 0, 0, 0); surtitle.fontSize = 10; surtitle.alignment = TextAnchor.MiddleLeft; surtitle.wordWrap = false; subtitle = new GUIStyle(surtitle); subtitle.padding.bottom = 2; titleInverted = new GUIStyle(title); titleInverted.normal.textColor = ColorPalette.unityBackgroundDark; surtitleInverted = new GUIStyle(surtitle); surtitleInverted.normal.textColor = ColorPalette.unityBackgroundDark; subtitleInverted = new GUIStyle(subtitle); subtitleInverted.normal.textColor = ColorPalette.unityBackgroundDark; if (EditorGUIUtility.isProSkin) { portsBackground = new GUIStyle("In BigTitle") { padding = new RectOffset(0, 0, 6, 5) }; } else { TextureResolution[] textureResolution = { 2 }; var createTextureOptions = CreateTextureOptions.Scalable; EditorTexture normalTexture = BoltCore.Resources.LoadTexture($"Nodes/NodePortsBackground.png", textureResolution, createTextureOptions); portsBackground = new GUIStyle { normal = { background = normalTexture.Single() }, padding = new RectOffset(0, 0, 6, 5) }; } settingLabel = new GUIStyle(BoltCore.Styles.nodeLabel); settingLabel.padding.left = 0; settingLabel.padding.right = 5; settingLabel.wordWrap = false; settingLabel.clipping = TextClipping.Clip; }
public static EditorTexture Icon(this UnityObject obj) { var icon = (Texture2D)EditorGUIUtility.ObjectContent(obj, obj?.GetType()).image; if (icon != null) { return(EditorTexture.Single(icon)); } return(null); }
public void Load() { variablesWindow = resources.LoadIcon("VariablesWindow.png"); variable = resources.LoadIcon("Variable.png"); graphVariable = resources.LoadIcon("GraphVariable.png"); objectVariable = resources.LoadIcon("ObjectVariable.png"); sceneVariable = resources.LoadIcon("SceneVariable.png"); applicationVariable = resources.LoadIcon("ApplicationVariable.png"); savedVariable = resources.LoadIcon("SavedVariable.png"); flowVariable = resources.LoadIcon("FlowVariable.png"); window = resources.LoadIcon("GraphWindow.png"); inspectorWindow = resources.LoadIcon("GraphInspectorWindow.png"); if (GraphWindow.active != null) { GraphWindow.active.titleContent.image = window?[IconSize.Small]; } empty = EditorTexture.Single(ColorPalette.transparent.GetPixel()); // Messages questionMessage = resources.LoadIcon("Question.png"); warningMessage = resources.LoadIcon("Warning.png"); successMessage = resources.LoadIcon("Success.png"); errorMessage = resources.LoadIcon("Error.png"); // States warningState = resources.LoadIcon("Warning.png"); successState = resources.LoadIcon("Success.png"); errorState = resources.LoadIcon("Error.png"); progress = resources.LoadIcon("Progress.png"); // Versioning upgrade = resources.LoadIcon("Upgrade.png"); upToDate = resources.LoadIcon("UpToDate.png"); downgrade = resources.LoadIcon("Downgrade.png"); // Windows supportWindow = resources.LoadIcon("SupportWindow.png"); sidebarAnchorLeft = resources.LoadTexture("SidebarAnchorLeft.png", CreateTextureOptions.PixelPerfect); sidebarAnchorRight = resources.LoadTexture("SidebarAnchorRight.png", CreateTextureOptions.PixelPerfect); // Configuration editorPref = resources.LoadTexture("EditorPref.png", new TextureResolution[] { 12, 24 }, CreateTextureOptions.PixelPerfect); projectSetting = resources.LoadTexture("ProjectSetting.png", new TextureResolution[] { 12, 24 }, CreateTextureOptions.PixelPerfect); // Other @null = resources.LoadIcon("Null.png"); }
private static EditorTexture GetBuiltInUnityTypeIcon(Type type) { var icon = (Texture2D)EditorGUIUtility.ObjectContent(null, type).image; // Change the blank file icon to a Unity-logo file icon if (icon == EditorGUIUtility.FindTexture("DefaultAsset Icon")) { icon = EditorGUIUtility.FindTexture("ScriptableObject Icon"); } if (icon != null) { return(EditorTexture.Single(icon)); } return(null); }
private static EditorTexture GetScriptTypeIcon(string scriptName) { var scriptObject = (UnityObject)EditorGUIUtility_GetScriptObjectFromClass.Invoke(null, new object[] { scriptName }); if (scriptObject != null) { var scriptIcon = (Texture2D)EditorGUIUtility_GetIconForObject.Invoke(null, new object[] { scriptObject }); if (scriptIcon != null) { return(EditorTexture.Single(scriptIcon)); } } var scriptPath = AssetDatabase.GetAssetPath(scriptObject); if (scriptPath != null) { switch (Path.GetExtension(scriptPath)) { case ".js": return(EditorTexture.Single((Texture2D)EditorGUIUtility.IconContent("js Script Icon").image)); case ".cs": return(EditorTexture.Single((Texture2D)EditorGUIUtility.IconContent("cs Script Icon").image)); case ".boo": return(EditorTexture.Single((Texture2D)EditorGUIUtility.IconContent("boo Script Icon").image)); } } return(null); }
static Styles() { coordinatesLabel = new GUIStyle(EditorStyles.label); coordinatesLabel.normal.textColor = majorGridColor; coordinatesLabel.fontSize = 9; coordinatesLabel.normal.background = new Color(0.36f, 0.36f, 0.36f).GetPixel(); coordinatesLabel.padding = new RectOffset(4, 4, 4, 4); var nodeColorComparer = new NodeColorComparer(); squares = new Dictionary <NodeColor, GUIStyle>(nodeColorComparer); hexes = new Dictionary <NodeColor, GUIStyle>(nodeColorComparer); foreach (var nodeColor in nodeColors) { var squareOff = (GUIStyle)($"flow node {(int)nodeColor}"); var squareOn = (GUIStyle)($"flow node {(int)nodeColor} on"); var hexOff = (GUIStyle)($"flow node hex {(int)nodeColor}"); var hexOn = (GUIStyle)($"flow node hex {(int)nodeColor} on"); // For node styles: // - Border: 9-slice coordinates // - Padding: inner spacing from edge // - Margin: shadow / glow outside edge TextureResolution[] textureResolution = { 2 }; var createTextureOptions = CreateTextureOptions.Scalable; string path = "NodeFill"; EditorTexture normalTexture = BoltCore.Resources.LoadTexture($"{path}{nodeColor}.png", textureResolution, createTextureOptions); EditorTexture activeTexture = BoltCore.Resources.LoadTexture($"{path}{nodeColor}Active.png", textureResolution, createTextureOptions); EditorTexture hoverTexture = BoltCore.Resources.LoadTexture($"{path}{nodeColor}Hover.png", textureResolution, createTextureOptions); EditorTexture focusedTexture = BoltCore.Resources.LoadTexture($"{path}{nodeColor}Focused.png", textureResolution, createTextureOptions); var square = new GUIStyle { border = squareOff.border.Clone(), margin = new RectOffset(3, 3, 6, 9), padding = new RectOffset(5, 5, 6, 6), normal = { background = normalTexture.Single() }, active = { background = activeTexture.Single() }, hover = { background = hoverTexture.Single() }, focused = { background = focusedTexture.Single() } }; squares.Add(nodeColor, square); var hex = new GUIStyle { border = new RectOffset(25, 25, 23, 23), margin = new RectOffset(6, 6, 5, 7), padding = new RectOffset(17, 17, 10, 10), normal = { background = hexOff.normal.background }, active = { background = hexOff.normal.background }, hover = { background = hexOff.normal.background }, focused = { background = hexOn.normal.background } }; hexes.Add(nodeColor, hex); } var arrowResolutions = new TextureResolution[] { 32 }; var arrowOptions = CreateTextureOptions.Scalable; arrowUp = BoltCore.Resources.LoadTexture("ArrowUp.png", arrowResolutions, arrowOptions, false); arrowDown = BoltCore.Resources.LoadTexture("ArrowDown.png", arrowResolutions, arrowOptions, false); arrowLeft = BoltCore.Resources.LoadTexture("ArrowLeft.png", arrowResolutions, arrowOptions, false); arrowRight = BoltCore.Resources.LoadTexture("ArrowRight.png", arrowResolutions, arrowOptions, false); lockIcon = new GUIContent(LudiqGUIUtility.newSkin ? ((GUIStyle)"IN ThumbnailSelection").onActive.background : ((GUIStyle)"Icon.Locked").onNormal.background); if (EditorGUIUtility.isProSkin) { majorGridColor = new Color(0, 0, 0, majorGridColor.a * 1.5f); minorGridColor = new Color(0, 0, 0, minorGridColor.a * 1.5f); } dragAndDropPreviewBackground = new GUIStyle("TE NodeBox"); dragAndDropPreviewBackground.margin = new RectOffset(0, 0, 0, 0); dragAndDropPreviewBackground.padding = new RectOffset(6, 8, 4, 8); dragAndDropPreviewText = new GUIStyle(); dragAndDropPreviewText.fontSize = 11; dragAndDropPreviewText.normal.textColor = ColorPalette.unityForeground; dragAndDropPreviewText.imagePosition = ImagePosition.TextOnly; }
public Root(GUIContent header) { label = header.text; icon = EditorTexture.Single(header.image); }