void OnEnable() { genericFileIcon = EditorGUIUtility.ObjectContent(null, typeof(TextAsset)).image; isvrIcon = EditorGUIUtility.ObjectContent(null, typeof(TerrainCollider)).image; client = target as ISVR_FileRequestorClient; yetUnnamedNewFolder = string.Empty; }
private static Rect DrawIcon(GameObject gameObject, Rect rect) { const string defaultIconName = "GameObject Icon"; //get specific icon for this gameObject var content = EditorGUIUtility.ObjectContent(gameObject, typeof(GameObject)); var contentIcon = content.image; var contentRect = rect; contentRect.width = Style.iconWidth; //contentRect.height = Style.iconHeight; #if UNITY_2018_1_OR_NEWER contentRect.x = rect.xMax - contentRect.width; #else contentRect.x = rect.xMax; #endif //draw hierarchy background if (Event.current.type == EventType.Repaint) { Style.backgroundStyle.Draw(contentRect, false, false, false, false); } //draw specific icon if (contentIcon.name != defaultIconName) { GUI.Label(contentRect, contentIcon); } return(contentRect); }
private static void DrawIcon(Rect rect) { using (new ProfilerSample("Icon")) { var content = EditorGUIUtility.ObjectContent(currentGameObject, typeof(GameObject)); if (!content.image) { return; } content.tooltip = Preferences.Tooltips ? "Change Icon" : string.Empty; content.text = string.Empty; rect.yMin++; rect.xMin++; GUI.changed = false; GUI.Button(rect, content, EditorStyles.label); if (!GUI.changed) { return; } Undo.RegisterFullObjectHierarchyUndo(currentGameObject, "Icon Changed"); Utility.ShowIconSelector(currentGameObject, rect, true); } }
private void DrawComponent(ComponentWrapper wrapper) { var component = wrapper.Component; Type componentType = component.GetType(); // Header row GUILayout.BeginVertical(ComponentRowStyle); Texture icon = EditorGUIUtility.ObjectContent(component, componentType).image; string componentName = ObjectNames.NicifyVariableName(componentType.Name); GUIContent content = new GUIContent(componentName, icon); // Checkbox wrapper.Checked = EditorGUILayout.ToggleLeft(content, wrapper.Checked, wrapper.Checked ? ComponentLabelStyle : GUI.skin.label); if (wrapper.Checked) { // Draw property foldout if there are any serialized properties. if (wrapper.Properties.Any()) { wrapper.FoldOut = EditorGUILayout.Foldout(wrapper.FoldOut, componentName + " properties and fields"); if (wrapper.FoldOut) { ++EditorGUI.indentLevel; DrawProperties(wrapper.Properties); --EditorGUI.indentLevel; } } else { GUILayout.Label(componentName + " has no serialized properties."); } } GUILayout.EndVertical(); }
/// /// Item drawers implementations /// private static Rect DrawIcon(GameObject gameObject, Rect rect) { var content = EditorGUIUtility.ObjectContent(gameObject, typeof(GameObject)); var contentIcon = content.image; var contentRect = rect; contentRect.width = Style.iconWidth; //contentRect.height = Style.iconHeight; #if UNITY_2018_1_OR_NEWER contentRect.x = rect.xMax - contentRect.width; #else contentRect.x = rect.xMax; #endif if (Event.current.type == EventType.Repaint) { Style.backgroundStyle.Draw(contentRect, false, false, false, false); } if (contentIcon.name != Utility.defaultIconName) { GUI.Label(contentRect, contentIcon); } return(contentRect); }
public void GetContainerContents(Rect rect, bool droppingFor, out GUIContentRect iconContent, out GUIContentRect labelContent) { Texture icon; string resultString, resultTip; if (ObjectFieldProperty.hasMultipleDifferentValues) { icon = null; resultString = "-"; resultTip = null; } else { var @object = ObjectField; if (InterfaceableGUIHelper.IsProjectAsset(@object) && (@object is Component || @object is GameObject)) { icon = EditorGUIUtility.FindTexture("PrefabNormal Icon"); } else { icon = EditorGUIUtility.ObjectContent(@object, null).image; } resultString = resultTip = BuildEditorResultString(ResultType, ObjectField); if (resultString == null) { resultString = "null"; } } iconContent = icon == null ? new GUIContentRect(null, rect) : new GUIContentRect(new GUIContent(icon, resultTip), rect); labelContent = new GUIContentRect(new GUIContent(resultString, !droppingFor ? resultTip : null), rect); }
private static void GetObjectNodeContents(ObjectNode objectNode, out GUIContent iconContent, out GUIContent labelContent) { iconContent = null; labelContent = new GUIContent(objectNode.NodeName); Texture icon; if (objectNode.Object is GameObject) { if (objectNode.IsProjectAsset) { icon = EditorGUIUtility.FindTexture("PrefabNormal Icon"); } else { icon = EditorGUIUtility.ObjectContent(null, typeof(GameObject)).image; } } else { icon = EditorGUIUtility.ObjectContent(objectNode.Object, null).image; } if (icon != null) { iconContent = new GUIContent(icon); } }
void DrawIconForCurve(Curve curve, Rect area, float width, float padding) { // Get. GUIContent content = EditorGUIUtility.ObjectContent(null, curve.type); Texture icon = content.image; if (icon == null) { content = EditorGUIUtility.ObjectContent(null, typeof(ScriptableObject)); icon = content.image; } // Desired size. float iconHeight = width - 1.0f - 1.0f; // Row height. float iconAspect = (icon) ? icon.width / icon.height : 1.0f; float iconWidth = iconHeight * iconAspect; // Draw. if (icon) { GUI.DrawTexture(new Rect( area.x + padding + 1.0f, area.y + 1.0f, iconWidth, iconHeight ), icon); } }
public static Texture GetIcon(string typeName) { if (cachedIcons.ContainsKey(typeName)) { Texture cachedIcon = cachedIcons[typeName]; if (cachedIcon != null) { return(cachedIcon); } } GUIContent objectContent; foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { Type type = assembly.GetType(typeName); if (type != null) { objectContent = EditorGUIUtility.ObjectContent(null, type); if (objectContent.image != null) { // Cache it so we don't need to do expensive lookups next time cachedIcons[typeName] = objectContent.image; return(objectContent.image); } } } objectContent = EditorGUIUtility.ObjectContent(null, typeof(MonoScript)); // Cache it so we don't need to do expensive lookups next time cachedIcons[typeName] = objectContent.image; return(objectContent.image); }
public static Texture2D GetSymbolIcon(SymbolDefinition symbol) { if (symbolIcons == null) { LoadSymbolIcons(); } var icon = symbol.cachedIcon; if (icon) { return(icon); } icon = symbolIcons[ (int)symbol.kind, symbol.IsPublic | symbol.IsInternal ? 0 : symbol.IsProtected ? 1 : 2] ?? keywordIcon; var asReflectedType = symbol as ReflectedType; if (asReflectedType != null && typeof(Component).IsAssignableFrom(asReflectedType.GetReflectedType())) { var unityContent = EditorGUIUtility.ObjectContent(null, asReflectedType.GetReflectedType()); if (unityContent.image != null) { icon = unityContent.image as Texture2D ?? icon; } } symbol.cachedIcon = icon; return(icon); }
void ResolveTableCollection() { m_PossibleTableCollection.Clear(); m_Collection = LocalizationEditorSettings.GetCollectionFromTable(m_TargetTable); if (m_TargetTable.SharedData == null) { return; } m_SharedTableDataSerializedObject = new SerializedObject(m_TargetTable.SharedData); m_TableCollectionName = m_SharedTableDataSerializedObject.FindProperty("m_TableCollectionName"); if (m_Collection != null) { m_CollectionButton = new GUIContent("Select Collection", EditorGUIUtility.ObjectContent(m_Collection, m_Collection.GetType()).image); return; } m_SharedTableDataCollection = LocalizationEditorSettings.GetCollectionForSharedTableData(m_TargetTable.SharedData); if (m_SharedTableDataCollection != null) { return; } LocalizationEditorSettings.FindLooseStringTablesUsingSharedTableData(m_TargetTable.SharedData, m_PossibleTableCollection); }
/// <summary> /// Initializes the <see cref="Candlelight.LocalizableTextEditor"/> class. /// </summary> static LocalizableTextEditor() { EditorGizmos.RegisterGizmo( EditorGUIUtility.ObjectContent(null, typeof(UnityEngine.TextAsset)).image as Texture2D, typeof(LocalizableText).Name ); }
public void Update() { GUIContent gUIContent = EditorGUIUtility.ObjectContent(this.m_ObjectField.value, this.m_ObjectField.objectType); this.m_ObjectIcon.image = gUIContent.image; this.m_ObjectLabel.text = gUIContent.text; }
public void CreateHistoryItem(VisualTreeAsset template, Object item, VisualElement historyStack) { var itemElement = template.CloneTree(); //Label forwardItem = new Label(forwardStack[i].name); var itemElementIcon = itemElement.Q <Image>("Icon"); var icon = EditorGUIUtility.ObjectContent(item, item.GetType()).image; //var icon = EditorGUIUtility.IconContent(item.GetType().ToString()).image; itemElementIcon.image = icon; var itemElementName = itemElement.Q <Label>("Name"); itemElementName.text = item.name; var pingButton = itemElement.Q <Button>("Ping"); pingButton.tooltip = "Ping"; pingButton.clickable.clicked += () => { EditorGUIUtility.PingObject(item); }; itemElement.RegisterCallback <MouseDownEvent, Object>(HistoryItemMouseDown, item); historyStack.Add(itemElement); }
internal static void DrawTypeIcon(Rect position, GameObject obj, GrendelFolderComponent folderComponent) { GUIContent customIcon = new GUIContent(); GUIContent typeIcon = new GUIContent(); bool hasCustomIcon = false; Color previousGUIColor = GUI.color; customIcon = new GUIContent(EditorGUIUtility.ObjectContent(obj, obj.GetType())); if (folderComponent == null) { typeIcon = new GUIContent(EditorGUIUtility.ObjectContent(null, TryGetFirstNonTransformComponentType(obj.GetComponents <Component>()))); hasCustomIcon = (customIcon.image != sGameObjectIcon.image) && (customIcon.image != sPrefabIcon.image) && (customIcon.image != sPrefabModelIcon.image) && (customIcon.image != sPrefabNormalIcon.image); } else { Color folderColor = folderComponent.FolderColor; folderColor.a = 1f; GUI.color = Color.Lerp(GUI.color, folderColor, folderComponent.FolderColor.a); typeIcon = new GUIContent(GrendelEditorIcons.FolderIcon); } GUI.Label(position, hasCustomIcon ? customIcon.image : typeIcon.image, sCustomIconStyle); GUI.color = previousGUIColor; }
private void DrawElements(Rect originalRect, ComponentToCopy component) { Rect rect = new Rect(originalRect); bool isRectTransform = component.Component is RectTransform; bool isTransform = component.Component is Transform || isRectTransform; if (isTransform) { rect.x += 14; rect.y -= 2; } //Enable/Disable Toggle Handler rect.x += 5; rect.y += 2; rect.width = rect.height = 20; component.IsCopyComponent = EditorGUI.Toggle(rect, component.IsCopyComponent); // Component Icon rect.x += 20; Texture componentIcon = EditorGUIUtility.ObjectContent(null, component.Component.GetType()).image; EditorGUI.LabelField(rect, new GUIContent(componentIcon)); // Component name. rect.x += 20; //rect.y = originalRect.y; rect.width = originalRect.width - 30; EditorGUI.LabelField(rect, component.ComponentName); }
public override void OnBodyContentGUI() { if (catergorySelection == componentCatergories.Count - 1) { DrawCustoms(); return; } //Draw all components for the catergory foreach (ComponentType component in currentComponents) { GUIContent content = EditorGUIUtility.ObjectContent(null, component.type); //Do not display if it's irrelevant in the first place if (content.image == null || content.image.name == "d_DefaultAsset Icon") { continue; } content.text = component.name; EditorGUILayout.BeginHorizontal(); { component.shown = EditorGUILayout.Toggle(component.shown); EditorGUILayout.LabelField(content); } EditorGUILayout.EndHorizontal(); } }
public static void ObjectLabelField(Rect position, Object value, GUIStyle style) { int controlID = GUIUtility.GetControlID(FocusType.Passive); switch (Event.current.GetTypeForControl(controlID)) { case EventType.Repaint: { GUIContent label; if (value != null) { label = EditorGUIUtility.ObjectContent(value, value.GetType()); } else { label = new GUIContent("null", EditorGUIUtility.FindTexture("CollabConflict")); } EditorGUI.LabelField(position, label); } break; case EventType.MouseDown: if (position.Contains(Event.current.mousePosition) && (Event.current.button == 0)) { EditorGUIUtility.PingObject(value); } break; } }
static Rect DrawElement_Removed(GameObject gameObject, Object removedObjectOnPrefab, Rect rect) { Rect buttonRect = GetRightAligned(rect, 12, 12); var icon = EditorGUIUtility.ObjectContent(removedObjectOnPrefab, removedObjectOnPrefab.GetType()).image; var description = string.Concat("Removed: ", removedObjectOnPrefab.GetType().Name); var result = GUI.Button(buttonRect, new GUIContent(" ", description), "flow node 6"); if (icon) { GUI.DrawTexture(buttonRect, icon); } if (result) { var prefab = PrefabUtility.GetPrefabParent(gameObject); //var selection = Selection.objects; Selection.objects = new[] { gameObject }; // PrefabMenu.missingComponentToRemove = removedObjectOnPrefab; // EditorUtility.DisplayPopupMenu(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0), "Prefab/Removed Component", null); //Selection.objects = selection; } return(new Rect(rect.x, rect.y, buttonRect.x - rect.x - 2, rect.height)); }
private static void OnHierarchyWindowItemGUI(int instanceID, Rect selectionRect) { if (iconStyle == IconStyle.None) { return; } GameObject go = EditorUtility.InstanceIDToObject(instanceID) as GameObject; float posX = (iconAlignment == IconAlignment.Left) ? 0 : Screen.width - 32; if (iconStyle == IconStyle.Gizmo) { Texture gizmoIcon = EditorGUIUtility.ObjectContent(go, typeof(GameObject)).image; if (go && gizmoIcon) { GUI.DrawTexture(new Rect(posX, selectionRect.y, 16, 16), gizmoIcon); } } else if (iconStyle == IconStyle.AssetPreview) { Texture previewIcon = AssetPreview.GetAssetPreview(PrefabUtility.GetPrefabParent(go)); if (go && previewIcon) { GUI.DrawTexture(new Rect(posX, selectionRect.y, 16, 16), previewIcon); } } }
public override void draw(GameObject gameObject, QObjectList objectList, Rect selectionRect) { for (int i = components.Count - componentsToDraw, n = components.Count; i < n; i++) { Component component = components[i]; if (component is Transform) { continue; } GUIContent content = EditorGUIUtility.ObjectContent(component, null); bool enabled = true; try { PropertyInfo propertyInfo = component.GetType().GetProperty("enabled"); enabled = (bool)propertyInfo.GetGetMethod().Invoke(component, null); } catch {} Color color = GUI.color; color.a = enabled ? 1f : 0.3f; GUI.color = color; GUI.DrawTexture(rect, content.image == null ? componentIcon : content.image, ScaleMode.ScaleToFit); color.a = 1; GUI.color = color; if (rect.Contains(Event.current.mousePosition)) { string componentName = "Missing script"; if (component != null) { componentName = component.GetType().Name; } int labelWidth = Mathf.CeilToInt(hintLabelStyle.CalcSize(new GUIContent(componentName)).x); selectionRect.x = rect.x - labelWidth / 2 - 4; selectionRect.width = labelWidth + 8; selectionRect.height -= 1; if (selectionRect.y > 16) { selectionRect.y -= 16; } else { selectionRect.x += labelWidth / 2 + 18; } EditorGUI.DrawRect(selectionRect, backgroundDarkColor); selectionRect.x += 4; selectionRect.y += (EditorGUIUtility.singleLineHeight - rect.height) * 0.5f; selectionRect.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(selectionRect, componentName, hintLabelStyle); } rect.x += rect.width + 2; } }
private void AssetGUI(AssetInfoBase asset, int indentation) { AssetFileInfo fileInfo = asset as AssetFileInfo; AssetFolderInfo folderInfo = asset as AssetFolderInfo; if (fileInfo != null) { if ((_hideInvalidAsset && !fileInfo.IsValid) || (_hideBundleAsset && fileInfo.Bundled != "")) { return; } } GUILayout.BeginHorizontal(); GUILayout.Space(indentation * 20 + 5); if (folderInfo != null) { GUIContent content = EditorGUIUtility.IconContent("Folder Icon"); content.text = folderInfo.Name; folderInfo.IsExpanding = EditorGUILayout.Foldout(folderInfo.IsExpanding, content, true); } else { GUI.enabled = fileInfo.IsValid; GUI.color = (_currentFile == fileInfo ? Color.cyan : (fileInfo.IsRedundant ? Color.red : Color.white)); GUILayout.Space(10); GUIContent content = EditorGUIUtility.ObjectContent(null, fileInfo.AssetType); content.text = fileInfo.Name; if (GUILayout.Button(content, _prefabLabel, GUILayout.Height(20))) { _currentFile = fileInfo; } if (fileInfo.Bundled != "") { GUILayout.Label("[" + fileInfo.Bundled + "]", _prefabLabel); } GUI.color = Color.white; GUI.enabled = true; if (fileInfo.IsRedundant) { GUILayout.Label(_redundant, _brokenPrefabLabel, GUILayout.Height(20)); } } _assetViewHeight += 20; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (folderInfo != null && folderInfo.IsExpanding) { folderInfo.ReadChildAsset(); for (int i = 0; i < folderInfo.ChildAsset.Count; i++) { AssetGUI(folderInfo.ChildAsset[i], indentation + 1); } } }
void OnGUI() { this.ScrollPosition = GUILayout.BeginScrollView(this.ScrollPosition); foreach (var referent in Results.Keys.OrderBy(key => key.Name).ToList()) { Foldouts.AddSafety(referent, true); if (Foldouts[referent] = EditorGUILayout.Foldout(Foldouts[referent], referent.Name)) { foreach (var target in Results[referent]) { var iconSize = EditorGUIUtility.GetIconSize(); EditorGUIUtility.SetIconSize(Vector2.one * 16); var obj = target.ToObject(); var content = new GUIContent(target.Name, EditorGUIUtility.ObjectContent(obj, obj.GetType()).image); if (GUILayout.Button(content, "Label")) { Selection.objects = new [] { obj }; } EditorGUIUtility.SetIconSize(iconSize); } } } GUILayout.EndScrollView(); }
private void RedundantAssetGUI() { foreach (KeyValuePair <string, AssetFileInfo> file in AssetBundleEditorUtility.FileInfos) { if (file.Value.IsRedundant) { GUILayout.BeginHorizontal(); GUILayout.Space(5); GUI.color = (_currentFile == file.Value ? Color.cyan : Color.red); GUILayout.Space(10); GUIContent content = EditorGUIUtility.ObjectContent(null, file.Value.AssetType); content.text = file.Value.Name; if (GUILayout.Button(content, _prefabLabel, GUILayout.Height(20))) { _currentFile = file.Value; } if (file.Value.Bundled != "") { GUILayout.Label("[" + file.Value.Bundled + "]", _prefabLabel); } GUI.color = Color.white; GUILayout.Label(_redundant, _brokenPrefabLabel, GUILayout.Height(20)); _assetViewHeight += 20; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } }
private void DrawTypeCell(Rect cellRect, TreeViewItem item) { CenterRectUsingSingleLineHeight(ref cellRect); var treeViewItem = item as AssetTreeViewItem; if (treeViewItem != null) { Texture icon; // Set icon by localized asset value type. var valueType = treeViewItem.LocalizedAsset.ValueType; if (valueType == typeof(string)) { icon = EditorGUIUtility.ObjectContent(null, typeof(TextAsset)).image; } else { icon = EditorGUIUtility.ObjectContent(null, valueType).image; } // Set default icon if not exist. if (!icon) { icon = EditorGUIUtility.ObjectContent(null, typeof(ScriptableObject)).image; } if (icon) { GUI.DrawTexture(cellRect, icon, ScaleMode.ScaleToFit); } } }
void OnGUI() { switch (Event.current.type) { case EventType.Repaint: tracker.ClearDirty(); break; } searchObject = EditorGUILayout.ObjectField("Search Object", searchObject, typeof(Object), true); drawSeparator(); using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollPosition)) { if (!!searchObject) { foreach (var hitGameObject in hitGameObjects) { var content = EditorGUIUtility.ObjectContent(hitGameObject, typeof(GameObject)); if (GUILayout.Button(content, EditorStyles.label, GUILayout.Height(EditorGUIUtility.singleLineHeight))) { EditorGUIUtility.PingObject(hitGameObject); Selection.activeGameObject = hitGameObject; } } } scrollPosition = scrollViewScope.scrollPosition; } }
public void Update() { GUIContent content = EditorGUIUtility.ObjectContent(m_ObjectField.value, m_ObjectField.objectType); m_ObjectIcon.image = content.image; m_ObjectLabel.text = content.text; }
public virtual void OnEnable() { m_TableEditorButton = new GUIContent("Open Table Editor", EditorGUIUtility.ObjectContent(target, typeof(LocalizedTable)).image); m_LocaleId = serializedObject.FindProperty("m_LocaleId"); m_TableName = serializedObject.FindProperty("m_TableName"); Undo.undoRedoPerformed += UndoRedoPerformed; }
// 绘制图标 private static void DrawIcon <T>(Rect rect) { // 获得Unity内置的图标 var icon = EditorGUIUtility.ObjectContent(null, typeof(T)).image; GUI.Label(rect, icon); }
private void DrawComponent(Rect rect, Type type, GameObject instance, Settings settings) { // Need to check for specifics if globally all components are not on if (!settings.globalData.showAllComponents) { ComponentType componentType = settings.componentData.unityComponents.FirstOrDefault(t => t.type == type); if (componentType == null) { componentType = settings.componentData.customComponents.FirstOrDefault(t => t.type == type); } if (componentType == null || !componentType.shown) { return; } } GUIContent content = EditorGUIUtility.ObjectContent(null, type); if (content.image == null) { return; } componentTypes.Add(type); DrawComponentIcon(rect, content, type); }