private void OnGUI() { if (!visible || !block) { return; } if (!AdvancedBuildingMod.Nuterra && AdvancedBuildingMod.ModExists("Nuterra.UI", out Assembly asm)) { var type = asm.GetTypes().First(t => t.Name.Contains("NuterraGUI")); AdvancedBuildingMod.Nuterra = (GUISkin)type.GetProperty("Skin").GetValue(null, null); } if (AdvancedBuildingMod.Nuterra) { GUI.skin = AdvancedBuildingMod.Nuterra; } if (!registered && AdvancedBuildingMod.ModExists("Exund.CommandConsole", out asm)) { var cmdctor = asm.GetTypes().First(t => t.Name.Contains("TTCommand")).GetConstructors()[0]; cmdctor.Invoke(new object[] { "BlockInfo", "Get the selected block info in console", new Func <Dictionary <string, string>, string>(delegate(Dictionary <string, string> arguments) { if (!block) { return("<color=yellow>No block selected</color>"); } string info = block.BlockType.ToString() + "\n" + block.CurrentMass; return(info); }), new Dictionary <string, string> { } }); registered = true; } /*GUI.skin = NuterraGUI.Skin;/*.window = new GUIStyle(GUI.skin.window) * { * normal = * { * background = NuterraGUI.LoadImage("Border_BG.png"), * textColor = Color.white * }, * border = new RectOffset(16, 16, 16, 16), * }; * GUI.skin.label.margin.top = 5; * GUI.skin.label.margin.bottom = 0;*/ try { win = GUI.Window(ID, win, new GUI.WindowFunction(DoWindow), "Block Infos"); } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } }
private void SettingsWindow(int id) { GUILayout.Label("Position step"); position_step = AdvancedBuildingMod.NumberField(position_step); AdvancedBuildingMod.transformGizmo.movementSnap = position_step; GUILayout.Label("Rotation step"); rotation_step = AdvancedBuildingMod.NumberField(rotation_step); AdvancedBuildingMod.transformGizmo.rotationSnap = rotation_step; GUILayout.Label("Scale step"); scale_step = AdvancedBuildingMod.NumberField(scale_step); AdvancedBuildingMod.transformGizmo.scaleSnap = scale_step; if (GUILayout.Button("Close")) { Settings_visible = false; SaveConfig(); } }
private void DoWindow(int id) { GUILayout.Label("X scale"); x = AdvancedBuildingMod.NumberField(x, 0.1f); //float.TryParse(GUILayout.TextField(x.ToString()), out x); GUILayout.Label("Y scale"); y = AdvancedBuildingMod.NumberField(y, 0.1f); //float.TryParse(GUILayout.TextField(y.ToString()), out y); GUILayout.Label("Z scale"); z = AdvancedBuildingMod.NumberField(z, 0.1f); //float.TryParse(GUILayout.TextField(z.ToString()), out z); if (GUILayout.Button("Close")) { visible = false; block = null; } GUI.DragWindow(); }
private void DoWindow(int id) { GUILayout.Label("X rotation"); x = AdvancedBuildingMod.NumberField(x, 15f); //float.TryParse(GUILayout.TextField(x.ToString()),out x); GUILayout.Label("Y rotation"); y = AdvancedBuildingMod.NumberField(y, 15f); //float.TryParse(GUILayout.TextField(y.ToString()), out y); GUILayout.Label("Z rotation"); z = AdvancedBuildingMod.NumberField(z, 15f); //float.TryParse(GUILayout.TextField(z.ToString()), out z); //GUILayout.Label(block.cachedLocalRotation.ToString()); if (GUILayout.Button("Close")) { visible = false; block = null; } GUI.DragWindow(); }
private void DoWindow(int id) { GUILayout.Label("X position"); x = AdvancedBuildingMod.NumberField(x, 0.125f); //float.TryParse(GUILayout.TextField(x.ToString()), out x); GUILayout.Label("Y position"); y = AdvancedBuildingMod.NumberField(y, 0.125f); //float.TryParse(GUILayout.TextField(y.ToString()), out y); GUILayout.Label("Z position"); z = AdvancedBuildingMod.NumberField(z, 0.125f); //float.TryParse(GUILayout.TextField(z.ToString()), out z); //GUILayout.Label(((IntVector3)block.trans.localPosition).ToString()); if (GUILayout.Button("Close")) { visible = false; block = null; } GUI.DragWindow(); }
private void TransformWindow(int id) { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); { GUILayout.BeginVertical(GUILayout.Width(150f)); var x = position.x; var y = position.y; var z = position.z; GUILayout.Label("X position"); x = AdvancedBuildingMod.NumberField(x, position_step); GUILayout.Label("Y position"); y = AdvancedBuildingMod.NumberField(y, position_step); GUILayout.Label("Z position"); z = AdvancedBuildingMod.NumberField(z, position_step); GUILayout.BeginHorizontal(); if (GUILayout.Button("Snap to closest")) { x = Mathf.Round(x / position_step) * position_step; y = Mathf.Round(y / position_step) * position_step; z = Mathf.Round(z / position_step) * position_step; } position = new Vector3(x, y, z); if (GUILayout.Button("Reset")) { position = block.cachedLocalPosition; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUILayout.FlexibleSpace(); { GUILayout.BeginVertical(GUILayout.Width(150f)); var x = rotation.x; var y = rotation.y; var z = rotation.z; GUILayout.Label("X rotation"); x = AdvancedBuildingMod.NumberField(x, rotation_step); GUILayout.Label("Y rotation"); y = AdvancedBuildingMod.NumberField(y, rotation_step); GUILayout.Label("Z rotation"); z = AdvancedBuildingMod.NumberField(z, rotation_step); GUILayout.BeginHorizontal(); if (GUILayout.Button("Snap to closest")) { x = Mathf.Round(x / rotation_step) * rotation_step; y = Mathf.Round(y / rotation_step) * rotation_step; z = Mathf.Round(z / rotation_step) * rotation_step; } rotation = new Vector3(x, y, z); if (GUILayout.Button("Reset")) { rotation = block.cachedLocalRotation.ToEulers(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUILayout.FlexibleSpace(); { GUILayout.BeginVertical(GUILayout.Width(150f)); var x = scale.x; var y = scale.y; var z = scale.z; GUILayout.Label("X scale"); x = AdvancedBuildingMod.NumberField(x, scale_step); GUILayout.Label("Y scale"); y = AdvancedBuildingMod.NumberField(y, scale_step); GUILayout.Label("Z scale"); z = AdvancedBuildingMod.NumberField(z, scale_step); GUILayout.BeginHorizontal(); if (GUILayout.Button("Snap to closest")) { x = Mathf.Round(x / scale_step) * scale_step; y = Mathf.Round(y / scale_step) * scale_step; z = Mathf.Round(z / scale_step) * scale_step; } scale = new Vector3(x, y, z); if (GUILayout.Button("Reset")) { scale = Vector3.one; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (GUILayout.Button("Open settings")) { Settings_visible = true; } GUILayout.FlexibleSpace(); }