void DrawColorControl(string name, ref Color value, ColorPicker.OnColorChanged onColorChanged) { GUILayout.BeginHorizontal(); GUILayout.Label(name); GUILayout.FlexibleSpace(); GUIControls.ColorField(name, "", ref value, 0.0f, null, true, true, onColorChanged); GUILayout.EndHorizontal(); }
public void Initialize(SimulationManager.UpdateMode _updateMode) { updateMode = _updateMode; if (!loggingInitialized) { Application.logMessageReceived += (condition, trace, type) => { if (!logExceptionsToConsole) { return; } if (Instance.console != null) { Instance.console.AddMessage(String.Format("{0} ({1})", condition, trace), type, true); return; } if (type == LogType.Error || type == LogType.Exception || type == LogType.Assert) { Log.Error(condition); } else if (type == LogType.Warning) { Log.Warning(condition); } else { Log.Message(condition); } }; loggingInitialized = true; } sceneExplorer = gameObject.AddComponent<SceneExplorer>(); watches = gameObject.AddComponent<Watches>(); colorPicker = gameObject.AddComponent<ColorPicker>(); sceneExplorerColorConfig = gameObject.AddComponent<SceneExplorerColorConfig>(); LoadConfig(); if (extendGamePanels && (updateMode == SimulationManager.UpdateMode.NewGame || updateMode == SimulationManager.UpdateMode.LoadGame)) { panelExtender = gameObject.AddComponent<GamePanelExtender>(); } if (useModToolsConsole) { console = gameObject.AddComponent<Console>(); } if (config.hookUnityLogging) { UnityLoggingHook.EnableHook(); } if (updateMode == SimulationManager.UpdateMode.Undefined && config.improvedWorkshopIntegration) { ImprovedWorkshopIntegration.Bootstrap(); } }
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(); }
static public 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(); }
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; 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 void Initialize(SimulationManager.UpdateMode _updateMode) { updateMode = _updateMode; if (!loggingInitialized) { Application.logMessageReceived += (condition, trace, type) => { if (!logExceptionsToConsole) { return; } if (Instance.console != null) { Instance.console.AddMessage(String.Format("{0} ({1})", condition, trace), type, true); return; } if (type == LogType.Error || type == LogType.Exception || type == LogType.Assert) { Log.Error(condition); } else if (type == LogType.Warning) { Log.Warning(condition); } else { Log.Message(condition); } }; loggingInitialized = true; } sceneExplorer = gameObject.AddComponent <SceneExplorer>(); watches = gameObject.AddComponent <Watches>(); colorPicker = gameObject.AddComponent <ColorPicker>(); sceneExplorerColorConfig = gameObject.AddComponent <SceneExplorerColorConfig>(); LoadConfig(); if (extendGamePanels && (updateMode == SimulationManager.UpdateMode.NewGame || updateMode == SimulationManager.UpdateMode.LoadGame)) { panelExtender = gameObject.AddComponent <GamePanelExtender>(); } if (useModToolsConsole) { console = gameObject.AddComponent <Console>(); } if (config.hookUnityLogging) { UnityLoggingHook.EnableHook(); } if (updateMode == SimulationManager.UpdateMode.Undefined && config.improvedWorkshopIntegration) { ImprovedWorkshopIntegration.Bootstrap(); } }