private static void DrawFixed(SerializedProperty fixedProperty, ColorType type1, ColorType fixedType) { Rect position = EditorGUILayout.GetControlRect(); Rect left = new Rect(position.x, position.y, EditorGUIUtility.labelWidth, position.height); Rect right = new Rect(position.x + EditorGUIUtility.labelWidth, position.y, position.width - EditorGUIUtility.labelWidth, position.height); EditorGUI.BeginChangeCheck(); bool toggled = EditorGUI.ToggleLeft(left, "Fixed " + fixedType.ToString(), fixedProperty.floatValue >= 0); float defaultFixedValue = GetDefaultFixedValue(fixedType); if (EditorGUI.EndChangeCheck()) { if (toggled) fixedProperty.floatValue = defaultFixedValue; else fixedProperty.floatValue = -1; } GUI.enabled = toggled; if (toggled) { fixedProperty.floatValue = EditorGUI.Slider(right, fixedProperty.floatValue, 0, 1); } else { EditorGUI.Slider(right, defaultFixedValue < 0 ? 0 : defaultFixedValue, 0, 1); } GUI.enabled = true; }
ThemeColor CreateThemeColor(ColorType colorType) { var hl = new ThemeColor { Name = colorType.ToString() }; var colorInfo = colorInfos[ToIndex(colorType)]; if (colorInfo.DefaultForeground != null) hl.Foreground = CreateColor(colorInfo.DefaultForeground); if (colorInfo.DefaultBackground != null) hl.Background = CreateColor(colorInfo.DefaultBackground); if (colorInfo.DefaultColor3 != null) hl.Color3 = CreateColor(colorInfo.DefaultColor3); if (colorInfo.DefaultColor4 != null) hl.Color4 = CreateColor(colorInfo.DefaultColor4); return hl; }
private static void CreateCircle(ColorType anlge, ColorType distance) { ColorPicker picker = GetColorPicker(); GameObject result; if (CreateGameObject(out result)) { SetRectTransformSize(result.transform as RectTransform, 150, 150); result.name = "Circle_" + anlge + distance.ToString().Substring(distance.ToString().Length - 1); // Handle slider area RectTransform handleArea = new GameObject("HandleArea").AddComponent<RectTransform>(); handleArea.SetParent(result.transform, false); SetRectTransformSize(handleArea, Vector2.zero, Vector2.one, new Vector2(6, 6)); // Handle RectTransform handleRect = new GameObject("Handle").AddComponent<RectTransform>(); handleRect.SetParent(handleArea, false); SetRectTransformSize(handleRect, 12, 12); Image handle = handleRect.gameObject.AddComponent<Image>(); handle.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/Knob.psd"); // Slider SliderCircle2D slider = result.AddComponent<SliderCircle2D>(); slider.handleRect = handleRect; slider.targetGraphic = handle; // Circle GradientCircle circle = result.AddComponent<GradientCircle>(); circle.ValueType1 = anlge; circle.ValueType2 = distance; circle.Picker = picker; } }
private static void CreateBox(ColorType x, ColorType y) { ColorPicker picker = GetColorPicker(); GameObject result; if (CreateGameObject(out result)) { SetRectTransformSize(result.transform as RectTransform, 150, 150); result.name = "GradientBox_" + x + y.ToString().Substring(y.ToString().Length - 1); // Handle slider area RectTransform handleArea = new GameObject("HandleArea").AddComponent<RectTransform>(); handleArea.SetParent(result.transform, false); SetRectTransformSize(handleArea, Vector2.zero, Vector2.one, new Vector2(6, 6)); // Handle RectTransform handleRect = new GameObject("Handle").AddComponent<RectTransform>(); handleRect.SetParent(handleArea, false); SetRectTransformSize(handleRect, 12, 12); Image handle = handleRect.gameObject.AddComponent<Image>(); handle.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/Knob.psd"); // Slider Slider2D slider = result.AddComponent<Slider2D>(); slider.handleRect = handleRect; slider.targetGraphic = handle; // Box GradientBox box = result.AddComponent<GradientBox>(); box.ValueType1 = x; box.ValueType2 = y; box.Picker = picker; } }
public override string ToString() { return(colorType.ToString()); }
public override string ToString() { return("Shape: " + shapeType.ToString() + " Color: " + colorType.ToString()); }
static public void Log(this Debug target, ColorType color, string arg) { Debug.Log(string.Format("<color={0}>{1}</color>", color.ToString(), arg)); }
private int GetMinimum(ColorType type) { switch (type) { case ColorType.RGB_R: case ColorType.RGB_G: case ColorType.RGB_B: case ColorType.HSV_V: case ColorType.HSL_S: return 2; case ColorType.HSV_S: return 2; case ColorType.HSV_H: case ColorType.HSL_H: return 7; case ColorType.HSL_L: return 3; default: throw new NotImplementedException(type.ToString()); } }
public static void InfoFormat(ColorType color, string szFormat, params object[] p) { WriteFileLog(string.Format(szFormat, p), LogLevel.INFO); UnityEngine.Debug.Log(string.Format("<color={0}>{1}</color>", color.ToString(), string.Format(szFormat, p))); }
static public void LogFormat(this Debug target, ColorType color, string format, params object[] args) { Debug.Log(string.Format("<color={0}>{1}</color>", color.ToString(), string.Format(format, args))); }
public static void DebugFormat(ColorType color, string logString) { WriteFileLog(logString, LogLevel.DEBUG); UnityEngine.Debug.Log(string.Format("<color={0}>{1}</color>", color.ToString(), logString)); }
public static void Info(ColorType color, object log) { WriteFileLog(log.ToString(), LogLevel.INFO); UnityEngine.Debug.Log(string.Format("<color={0}>{1}</color>", color.ToString(), log)); }
/// <summary> /// 初始化 /// </summary> public override void Init() { isCenter = true; if (Group.Length == 0) { if (Goal == null) { bufGoal = transform; } else { bufGoal = Goal; } Group = new Transform[1] { bufGoal }; } List <Material> mList = new List <Material>(); for (int i = 0; i < Group.Length; i++) { if (Group[i].GetComponent <MeshRenderer>() != null) { int l = Group[i].GetComponent <MeshRenderer>().materials.Length; for (int j = 0; j < l; j++) { mList.Add(Group[i].GetComponent <MeshRenderer>().materials[j]); } } if (Group[i].GetComponent <SkinnedMeshRenderer>() != null) { int l = Group[i].GetComponent <SkinnedMeshRenderer>().materials.Length; for (int j = 0; j < l; j++) { mList.Add(Group[i].GetComponent <SkinnedMeshRenderer>().materials[j]); } } if (Group[i].GetComponent <TrailRenderer>() != null) { int l = Group[i].GetComponent <TrailRenderer>().materials.Length; for (int j = 0; j < l; j++) { mList.Add(Group[i].GetComponent <TrailRenderer>().materials[j]); } } if (Group[i].GetComponent <Renderer>() != null) { int l = Group[i].GetComponent <Renderer>().materials.Length; for (int j = 0; j < l; j++) { mList.Add(Group[i].GetComponent <Renderer>().materials[j]); } } } material = new Material[mList.Count]; for (int i = 0; i < mList.Count; i++) { material[i] = mList[i]; } if (material.Length == 0) { Debug.LogError("没有材质"); return; } originalColor = new Color[material.Length]; distanceColor = new Color[material.Length]; for (int i = 0; i < material.Length; i++) { originalColor[i] = material[i].GetColor(Type.ToString()); //保存初始颜色 } base.Init(); }
MyHighlightingColor CreateHighlightingColor(ColorType colorType) { var hl = new MyHighlightingColor { Name = colorType.ToString() }; var colorInfo = colorInfos[(int)colorType]; if (colorInfo.DefaultForeground != null) hl.Foreground = CreateColor(colorInfo.DefaultForeground); if (colorInfo.DefaultBackground != null) hl.Background = CreateColor(colorInfo.DefaultBackground); if (colorInfo.DefaultColor3 != null) hl.Color3 = CreateColor(colorInfo.DefaultColor3); if (colorInfo.DefaultColor4 != null) hl.Color4 = CreateColor(colorInfo.DefaultColor4); return hl; }
ThemeColor ReadColor(XElement color, ref ColorType colorType) { var name = color.Attribute("name"); if (name == null) { return(null); } colorType = ToColorType(name.Value); if (colorType == ColorType.LastUI) { return(null); } var colorInfo = colorInfos[ToIndex(colorType)]; var hl = new ThemeColor(); hl.Name = colorType.ToString(); var fg = GetAttribute(color, "fg", colorInfo.DefaultForeground); if (fg != null) { hl.Foreground = CreateColor(fg); } var bg = GetAttribute(color, "bg", colorInfo.DefaultBackground); if (bg != null) { hl.Background = CreateColor(bg); } var color3 = GetAttribute(color, "color3", colorInfo.DefaultColor3); if (color3 != null) { hl.Color3 = CreateColor(color3); } var color4 = GetAttribute(color, "color4", colorInfo.DefaultColor4); if (color4 != null) { hl.Color4 = CreateColor(color4); } var italics = color.Attribute("italics") ?? color.Attribute("italic"); if (italics != null) { hl.FontStyle = (bool)italics ? FontStyles.Italic : FontStyles.Normal; } var bold = color.Attribute("bold"); if (bold != null) { hl.FontWeight = (bool)bold ? FontWeights.Bold : FontWeights.Normal; } return(hl); }
MyHighlightingColor ReadColor(XElement color, ref ColorType colorType) { var name = color.Attribute("name"); if (name == null) return null; colorType = ToColorType(name.Value); if (colorType == ColorType.Last) return null; var colorInfo = colorInfos[(int)colorType]; var hl = new MyHighlightingColor(); hl.Name = colorType.ToString(); var fg = GetAttribute(color, "fg", colorInfo.DefaultForeground); if (fg != null) hl.Foreground = CreateColor(fg); var bg = GetAttribute(color, "bg", colorInfo.DefaultBackground); if (bg != null) hl.Background = CreateColor(bg); var color3 = GetAttribute(color, "color3", colorInfo.DefaultColor3); if (color3 != null) hl.Color3 = CreateColor(color3); var color4 = GetAttribute(color, "color4", colorInfo.DefaultColor4); if (color4 != null) hl.Color4 = CreateColor(color4); var italics = color.Attribute("italics") ?? color.Attribute("italic"); if (italics != null) hl.FontStyle = (bool)italics ? FontStyles.Italic : FontStyles.Normal; var bold = color.Attribute("bold"); if (bold != null) hl.FontWeight = (bool)bold ? FontWeights.Bold : FontWeights.Normal; return hl; }
/// <summary> /// 获取预先定义的线性画笔资源 /// </summary> /// <param name="key">键</param> /// <returns></returns> public static Brush GetThemeBrush(ColorType key) { return((Brush)Application.Current.Resources[key.ToString()]); }