private void Apply(bool interactive) { uiText.Text.color = interactive ? enableColor : disableColor; var components = UnityUtility.GetComponents <Component>(gameObject).ToArray(); if (useShadow) { var shadowComponent = FindComponent <Shadow>(components); if (shadowComponent != null) { shadowComponent.effectColor = interactive ? enableShadowColor : disableShadowColor; } } if (useOutline) { var outlineComponent = FindComponent <Outline>(components); if (outlineComponent != null) { outlineComponent.effectColor = interactive ? enableOutlineColor : disableOutlineColor; } } }
public void Apply(TextEffectBase target) { Release(target); var softMaskable = IsSoftMaskable(target); var components = UnityUtility.GetComponents <TextEffectBase>(target.gameObject) .Where(x => x.Alive) .ToArray(); var cacheKey = GetCacheKey(components, softMaskable); var material = GetMaterial(cacheKey, components, softMaskable); if (material != null) { if (!reference.ContainsKey(material)) { reference.Add(material, new List <TextEffectBase>()); } if (target.Alive) { reference[material].Add(target); } } target.Text.material = material; }
public void ApplyColor() { if (string.IsNullOrEmpty(selectionGuid)) { return; } var info = setting.GetTextColorInfo(selectionGuid); if (info == null) { return; } var components = UnityUtility.GetComponents <Component>(gameObject).ToArray(); var textComponent = FindComponent <Text>(components); if (textComponent != null) { textComponent.color = info.textColor; } var textMeshProComponent = FindComponent <TextMeshProUGUI>(components); if (textMeshProComponent != null) { textMeshProComponent.color = info.textColor; } if (info.hasOutline) { var outlineComponent = FindComponent <Outline>(components); if (outlineComponent != null) { outlineComponent.effectColor = info.outlineColor; } if (textMeshProComponent != null) { textMeshProComponent.outlineColor = info.outlineColor; } } if (info.hasShadow) { var shadowComponent = FindComponent <Shadow>(components); if (shadowComponent != null) { shadowComponent.effectColor = info.shadowColor; } } }
/// <summary> /// Missing状態のComponent or Fieldがあるか取得. /// </summary> public static bool HasMissingReference(GameObject gameObject) { var components = UnityUtility.GetComponents <Component>(gameObject).ToArray(); // コンポーネントのスクリプトがMissing. if (components.Any(x => x == null)) { return(true); } // コンポーネントのSerializeFieldがMissing. foreach (var component in components) { var so = new SerializedObject(component); var sp = so.GetIterator(); while (sp.NextVisible(true)) { if (sp.propertyType != SerializedPropertyType.ObjectReference) { continue; } if (sp.objectReferenceValue != null) { continue; } if (!sp.hasChildren) { continue; } var fileId = sp.FindPropertyRelative("m_FileID"); if (fileId == null) { continue; } if (fileId.intValue == 0) { continue; } return(true); } } return(false); }
private void OnDrawHierarchy(int instandeID, Rect rect) { if (Application.isPlaying) { return; } if (!HierarchyComponentIcon.Prefs.enable) { return; } var go = EditorUtility.InstanceIDToObject(instandeID) as GameObject; if (go == null) { return; } var components = UnityUtility.GetComponents <Component>(go) .Where(x => x != null) .ToArray(); if (components.Any()) { var originIconSize = EditorGUIUtility.GetIconSize(); EditorGUIUtility.SetIconSize(new Vector2(IconSize, IconSize)); var padding = new Vector2(5, 0); var iconOffectX = IconSize + 1.5f; var iconDrawRect = new Rect(rect.xMax - (IconSize + padding.x), rect.yMin, rect.width, rect.height); foreach (var component in components) { var type = component.GetType(); var item = iconTextureCache.FirstOrDefault(x => type == x.Key || type.IsSubclassOf(x.Key)); if (item.Equals(default(KeyValuePair <Type, Texture>))) { continue; } DrawComponentIcon(iconDrawRect, item.Value); iconDrawRect.center = Vector.SetX(iconDrawRect.center, iconDrawRect.center.x - iconOffectX); } EditorGUIUtility.SetIconSize(originIconSize); } }
public override Rect Draw(GameObject targetObject, Rect rect) { rect.center = Vector.SetX(rect.center, rect.center.x - 2f); var components = UnityUtility.GetComponents <Component>(targetObject).ToArray(); var originIconSize = EditorGUIUtility.GetIconSize(); if (components.Any()) { using (new EditorGUIUtility.IconSizeScope(new Vector2(ComponentIconSize, ComponentIconSize))) { var iconOffsetX = ComponentIconSize + 1.5f; foreach (var component in components) { if (component == null) { continue; } var type = component.GetType(); var item = iconGUIContentDictionary.FirstOrDefault(x => type == x.Key || type.IsSubclassOf(x.Key)); if (item.IsDefault()) { continue; } var drawRect = rect; drawRect.center = Vector.SetY(rect.center, rect.center.y + 1f); EditorGUI.LabelField(drawRect, item.Value); rect.center = Vector.SetX(rect.center, rect.center.x - iconOffsetX); } } } EditorGUIUtility.SetIconSize(originIconSize); return(rect); }
//----- params ----- //----- field ----- //----- property ----- //----- method ----- public override void OnInspectorGUI() { var instance = target as TextColor; EditorGUI.BeginChangeCheck(); var setting = EditorGUILayout.ObjectField("Setting File", instance.Setting, typeof(TextColorSetting), false) as TextColorSetting; if (EditorGUI.EndChangeCheck()) { UnityEditorUtility.RegisterUndo("TextColorInspector Undo", instance); instance.Setting = setting; instance.TextColorName = null; } if (setting != null) { var infos = setting.ColorInfos.Where(x => !string.IsNullOrEmpty(x.name)).ToArray(); var textColorName = instance.TextColorName; var info = infos.FirstOrDefault(x => x.name == textColorName); var index = infos.IndexOf(x => x == info) + 1; var labels = new List <string> { "None" }; labels.AddRange(infos.Select(x => x.name)); using (new EditorGUILayout.HorizontalScope()) { EditorGUI.BeginChangeCheck(); var select = EditorGUILayout.Popup("ColorName", index, labels.ToArray()); if (EditorGUI.EndChangeCheck()) { UnityEditorUtility.RegisterUndo("TextColorInspector Undo", instance); var newTextColorName = string.Empty; if (select == 0) { newTextColorName = null; } else if (0 < select) { newTextColorName = infos[select - 1].name; } instance.TextColorName = newTextColorName; instance.ApplyColor(); } if (!string.IsNullOrEmpty(instance.TextColorName)) { if (GUILayout.Button("Apply", EditorStyles.miniButton, GUILayout.Width(75f), GUILayout.Height(15f))) { instance.ApplyColor(); } } } if (info != null) { var components = UnityUtility.GetComponents <Component>(instance.gameObject).ToArray(); if (info.hasOutline) { var hasOutline = HasComponent(components, new Type[] { typeof(Outline), typeof(TextOutline), typeof(RichTextOutline) }); if (!hasOutline) { EditorGUILayout.HelpBox("Require component Outline or TextOutline or RichTextOutline.", MessageType.Warning); } } if (info.hasShadow) { var hasShadow = HasComponent(components, new Type[] { typeof(Shadow), typeof(TextShadow), typeof(RichTextShadow) }); if (!hasShadow) { EditorGUILayout.HelpBox("Require component Shadow or TextShadow or RichTextShadow.", MessageType.Warning); } } } } }