static public void QuaternionField(string hash, string name, ref Quaternion value, float ident = 0.0f, WatchButtonCallback watch = null, bool noSpace = false, bool noTypeLabel = false) { GUILayout.BeginHorizontal(); if (ident != 0.0f) { GUILayout.Space(ident); } if (!noTypeLabel) { GUI.contentColor = config.typeColor; GUILayout.Label("Quaternion (euler)"); } GUI.contentColor = config.nameColor; GUILayout.Label(name); GUI.contentColor = config.valueColor; if (!noSpace) { GUILayout.FlexibleSpace(); } var euler = value.eulerAngles; FloatField(hash + ".x", "x", ref euler.x, 0.0f, true, true); FloatField(hash + ".y", "y", ref euler.y, 0.0f, true, true); FloatField(hash + ".z", "z", ref euler.z, 0.0f, true, true); if (euler != value.eulerAngles) { value = Quaternion.Euler(euler); } if (watch != null) { if (GUILayout.Button("Watch")) { watch(); } } GUI.contentColor = Color.white; GUILayout.EndHorizontal(); }
public static void Color32Field(string hash, string name, ref Color32 value, float ident = 0.0f, WatchButtonCallback watch = null, bool noSpace = false, bool noTypeLabel = false, ColorPicker.OnColor32Changed onColor32Changed = null) { GUILayout.BeginHorizontal(); if (ident != 0.0f) { GUILayout.Space(ident); } if (!noTypeLabel) { GUI.contentColor = config.typeColor; GUILayout.Label("Color"); } GUI.contentColor = config.nameColor; GUILayout.Label(name); GUI.contentColor = config.valueColor; if (!noSpace) { GUILayout.FlexibleSpace(); } ByteField(hash + ".r", "r", ref value.r, 0.0f, true, true); ByteField(hash + ".g", "g", ref value.g, 0.0f, true, true); ByteField(hash + ".b", "b", ref value.b, 0.0f, true, true); ByteField(hash + ".a", "a", ref value.a, 0.0f, true, true); if (onColor32Changed != null) { if (GUILayout.Button("", GUILayout.Width(72))) { var picker = ModTools.Instance.colorPicker; if (picker != null) { picker.SetColor(value, onColor32Changed); Vector2 mouse = Input.mousePosition; mouse.y = Screen.height - mouse.y; picker.rect.position = mouse; picker.visible = true; } } var lastRect = GUILayoutUtility.GetLastRect(); lastRect.x += 4.0f; lastRect.y += 4.0f; lastRect.width -= 8.0f; lastRect.height -= 8.0f; GUI.DrawTexture(lastRect, ColorPicker.GetColorTexture(hash, value), ScaleMode.StretchToFill); } if (watch != null) { if (GUILayout.Button("Watch")) { watch(); } } GUI.contentColor = Color.white; GUILayout.EndHorizontal(); }
static public void Vector4Field(string hash, string name, ref Vector4 value, float ident = 0.0f, WatchButtonCallback watch = null, bool noSpace = false, bool noTypeLabel = false) { GUILayout.BeginHorizontal(); if (ident != 0.0f) { GUILayout.Space(ident); } if (!noTypeLabel) { GUI.contentColor = config.typeColor; GUILayout.Label("Vector4"); } GUI.contentColor = config.nameColor; GUILayout.Label(name); GUI.contentColor = config.valueColor; if (!noSpace) { GUILayout.FlexibleSpace(); } FloatField(hash + ".x", "x", ref value.x, 0.0f, true, true); FloatField(hash + ".y", "y", ref value.y, 0.0f, true, true); FloatField(hash + ".z", "z", ref value.z, 0.0f, true, true); FloatField(hash + ".w", "w", ref value.w, 0.0f, true, true); if (watch != null) { if (GUILayout.Button("Watch")) { watch(); } } GUI.contentColor = Color.white; GUILayout.EndHorizontal(); }
static public void ColorField(string hash, string name, ref Color value, float ident = 0.0f, WatchButtonCallback watch = null, bool noSpace = false, bool noTypeLabel = false, ColorPicker.OnColorChanged onColorChanged = null) { GUILayout.BeginHorizontal(); if (ident != 0.0f) { GUILayout.Space(ident); } if (!noTypeLabel) { GUI.contentColor = config.typeColor; GUILayout.Label("Color"); } GUI.contentColor = config.nameColor; GUILayout.Label(name); GUI.contentColor = config.valueColor; if (!noSpace) { GUILayout.FlexibleSpace(); } var r = (byte)(Mathf.Clamp(value.r * 255.0f, Byte.MinValue, Byte.MaxValue)); var g = (byte)(Mathf.Clamp(value.g * 255.0f, Byte.MinValue, Byte.MaxValue)); var b = (byte)(Mathf.Clamp(value.b * 255.0f, Byte.MinValue, Byte.MaxValue)); var a = (byte)(Mathf.Clamp(value.a * 255.0f, Byte.MinValue, Byte.MaxValue)); ByteField(hash + ".r", "r", ref r, 0.0f, true, true); ByteField(hash + ".g", "g", ref g, 0.0f, true, true); ByteField(hash + ".b", "b", ref b, 0.0f, true, true); ByteField(hash + ".a", "a", ref a, 0.0f, true, true); value.r = Mathf.Clamp01((float)r / 255.0f); value.g = Mathf.Clamp01((float)g / 255.0f); value.b = Mathf.Clamp01((float)b / 255.0f); value.a = Mathf.Clamp01((float)a / 255.0f); if (onColorChanged != null) { if (value.r != r || value.g != g || value.b != b || value.a != a) { onColorChanged(value); } if (GUILayout.Button("", GUILayout.Width(72))) { var picker = ModTools.Instance.colorPicker; if (picker != null) { picker.SetColor(value, onColorChanged); Vector2 mouse = Input.mousePosition; mouse.y = Screen.height - mouse.y; picker.rect.position = mouse; picker.visible = true; } } var lastRect = GUILayoutUtility.GetLastRect(); lastRect.x += 4.0f; lastRect.y += 4.0f; lastRect.width -= 8.0f; lastRect.height -= 8.0f; GUI.DrawTexture(lastRect, ColorPicker.GetColorTexture(hash, value), ScaleMode.StretchToFill); } if (watch != null) { if (GUILayout.Button("Watch")) { watch(); } } GUI.contentColor = Color.white; GUILayout.EndHorizontal(); }
public static void QuaternionField(string hash, string name, ref Quaternion value, float ident = 0.0f, WatchButtonCallback watch = null, bool noSpace = false, bool noTypeLabel = false) { GUILayout.BeginHorizontal(); if (ident != 0.0f) { GUILayout.Space(ident); } if (!noTypeLabel) { GUI.contentColor = config.typeColor; GUILayout.Label("Vector4"); } GUI.contentColor = config.nameColor; GUILayout.Label(name); GUI.contentColor = config.valueColor; if (!noSpace) { GUILayout.FlexibleSpace(); } var euler = value.eulerAngles; FloatField(hash+".x", "x", ref euler.x, 0.0f, true, true); FloatField(hash+".y", "y", ref euler.y, 0.0f, true, true); FloatField(hash+".z", "z", ref euler.z, 0.0f, true, true); if (euler != value.eulerAngles) { value = Quaternion.Euler(euler); } if (watch != null) { if (GUILayout.Button("Watch")) { watch(); } } GUI.contentColor = Color.white; GUILayout.EndHorizontal(); }
public static void ColorField(string hash, string name, ref Color value, float ident = 0.0f, WatchButtonCallback watch = null, bool noSpace = false, bool noTypeLabel = false, ColorPicker.OnColorChanged onColorChanged = null) { GUILayout.BeginHorizontal(); if (ident != 0.0f) { GUILayout.Space(ident); } if (!noTypeLabel) { GUI.contentColor = config.typeColor; GUILayout.Label("Color"); } GUI.contentColor = config.nameColor; GUILayout.Label(name); GUI.contentColor = config.valueColor; if (!noSpace) { GUILayout.FlexibleSpace(); } var r = (byte)(Mathf.Clamp(value.r * 255.0f, Byte.MinValue, Byte.MaxValue)); var g = (byte)(Mathf.Clamp(value.g * 255.0f, Byte.MinValue, Byte.MaxValue)); var b = (byte)(Mathf.Clamp(value.b * 255.0f, Byte.MinValue, Byte.MaxValue)); var a = (byte)(Mathf.Clamp(value.a * 255.0f, Byte.MinValue, Byte.MaxValue)); ByteField(hash + ".r", "r", ref r, 0.0f, true, true); ByteField(hash + ".g", "g", ref g, 0.0f, true, true); ByteField(hash + ".b", "b", ref b, 0.0f, true, true); ByteField(hash + ".a", "a", ref a, 0.0f, true, true); value.r = Mathf.Clamp01((float)r / 255.0f); value.g = Mathf.Clamp01((float)g / 255.0f); value.b = Mathf.Clamp01((float)b / 255.0f); value.a = Mathf.Clamp01((float)a / 255.0f); if (onColorChanged != null) { if (value.r != r || value.g != g || value.b != b || value.a != a) { onColorChanged(value); } if (GUILayout.Button("", GUILayout.Width(72))) { var picker = ModTools.Instance.colorPicker; picker.SetColor(value, onColorChanged); Vector2 mouse = Input.mousePosition; mouse.y = Screen.height - mouse.y; picker.rect.position = mouse; picker.visible = true; } var lastRect = GUILayoutUtility.GetLastRect(); lastRect.x += 4.0f; lastRect.y += 4.0f; lastRect.width -= 8.0f; lastRect.height -= 8.0f; GUI.DrawTexture(lastRect, ColorPicker.GetColorTexture(hash, value), ScaleMode.StretchToFill); } if (watch != null) { if (GUILayout.Button("Watch")) { watch(); } } GUI.contentColor = Color.white; GUILayout.EndHorizontal(); }
public static void Color32Field(string hash, string name, ref Color32 value, float ident = 0.0f, WatchButtonCallback watch = null, bool noSpace = false, bool noTypeLabel = false, ColorPicker.OnColor32Changed onColor32Changed = null) { GUILayout.BeginHorizontal(); if (ident != 0.0f) { GUILayout.Space(ident); } if (!noTypeLabel) { GUI.contentColor = config.typeColor; GUILayout.Label("Color"); } GUI.contentColor = config.nameColor; GUILayout.Label(name); GUI.contentColor = config.valueColor; if (!noSpace) { GUILayout.FlexibleSpace(); } ByteField(hash+".r", "r", ref value.r, 0.0f, true, true); ByteField(hash+".g", "g", ref value.g, 0.0f, true, true); ByteField(hash+".b", "b", ref value.b, 0.0f, true, true); ByteField(hash+".a", "a", ref value.a, 0.0f, true, true); if (onColor32Changed != null) { if (GUILayout.Button("", GUILayout.Width(72))) { var picker = ModTools.Instance.colorPicker; picker.SetColor(value, onColor32Changed); Vector2 mouse = Input.mousePosition; mouse.y = Screen.height - mouse.y; picker.rect.position = mouse; picker.visible = true; } var lastRect = GUILayoutUtility.GetLastRect(); lastRect.x += 4.0f; lastRect.y += 4.0f; lastRect.width -= 8.0f; lastRect.height -= 8.0f; GUI.DrawTexture(lastRect, ColorPicker.GetColorTexture(hash, value), ScaleMode.StretchToFill); } if (watch != null) { if (GUILayout.Button("Watch")) { watch(); } } GUI.contentColor = Color.white; GUILayout.EndHorizontal(); }
public static void Vector4Field(string hash, string name, ref Vector4 value, float ident = 0.0f, WatchButtonCallback watch = null, bool noSpace = false, bool noTypeLabel = false) { GUILayout.BeginHorizontal(); if (ident != 0.0f) { GUILayout.Space(ident); } if (!noTypeLabel) { GUI.contentColor = config.typeColor; GUILayout.Label("Vector4"); } GUI.contentColor = config.nameColor; GUILayout.Label(name); GUI.contentColor = config.valueColor; if (!noSpace) { GUILayout.FlexibleSpace(); } FloatField(hash+".x", "x", ref value.x, 0.0f, true, true); FloatField(hash+".y", "y", ref value.y, 0.0f, true, true); FloatField(hash+".z", "z", ref value.z, 0.0f, true, true); FloatField(hash+".w", "w", ref value.w, 0.0f, true, true); if (watch != null) { if (GUILayout.Button("Watch")) { watch(); } } GUI.contentColor = Color.white; GUILayout.EndHorizontal(); }