/// <summary> /// Spawns an Instance of an defined StaticModel /// </summary> /// <param name="model"></param> /// <param name="fOffset"></param> /// <param name="vPosition"></param> /// <param name="fAngle"></param> /// <returns></returns> public string SpawnInstance(StaticModel model, float fOffset, Vector3 vPosition) { StaticInstance instance = new StaticInstance(); instance.Orientation = Vector3.up; instance.heighReference = HeightReference.Terrain; instance.VisibilityRange = (PhysicsGlobals.Instance.VesselRangesDefault.flying.unload + 3000); instance.Group = "SaveGame"; instance.RadialPosition = vPosition; instance.model = model; if (instance.model == null) { Log.UserError("LoadFromSave: Canot find model named: " + model.name); instance = null; } //instance.mesh = UnityEngine.Object.Instantiate(instance.model.prefab); instance.CelestialBody = KerbalKonstructs.instance.GetCurrentBody(); instance.RadiusOffset = fOffset; instance.RotationAngle = 0; instance.RefLatitude = KKMath.GetLatitudeInDeg(instance.RadialPosition); instance.RefLongitude = KKMath.GetLongitudeInDeg(instance.RadialPosition); InstanceUtil.CreateGroupCenterIfMissing(instance); bool oldLegacySpawn = KerbalKonstructs.convertLegacyConfigs; instance.Orientate(); instance.Activate(); KerbalKonstructs.convertLegacyConfigs = oldLegacySpawn; KerbalKonstructs.SelectInstance(instance, true); selectedInstance = instance; startPosition = selectedInstance.position; instance.Update(); instance.isInSavegame = true; instance.HighlightObject(XKCDColors.FreshGreen); this.Open(); return(instance.UUID); }
public void SpinPreview(StaticInstance soObject) { if (soObject == null || currPreview == null) { return; } float fRot = ((soObject.RotationAngle + 0.1f) % 360); soObject.RotationAngle = fRot; soObject.Update(); }
private void GrasSelectorWindow(int WindowID) { GUI.enabled = true; GUILayout.BeginHorizontal(); { GUI.enabled = false; GUILayout.Button("-KK-", UIMain.DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUILayout.Button(titleText, UIMain.DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUI.enabled = true; if (GUILayout.Button("X", UIMain.DeadButtonRed, GUILayout.Height(21))) { this.Close(); } } GUILayout.EndHorizontal(); GUILayout.Space(1); GUILayout.Box(UIMain.tHorizontalSep, UIMain.BoxNoBorder, GUILayout.Height(4)); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Select Preset", GUILayout.Height(23), GUILayout.Width(120))) { GrassColorPresetUI.callBack = UpdateCallBack; GrassColorPresetUI.instance.Open(); } GUILayout.Space(20); if (GUILayout.Button("Pick Surface Color", GUILayout.Height(23), GUILayout.Width(120))) { selectedInstance.GrasColor = GrassColorUtils.GetUnderGroundColor(selectedInstance); selectedInstance.Update(); SetupFields(); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.Space(3); GUI.enabled = true; { GUILayout.BeginHorizontal(); { GUILayout.Label("Red: ", GUILayout.Height(23)); GUILayout.FlexibleSpace(); grasColorRStr = (GUILayout.TextField(grasColorRStr, 7, GUILayout.Width(90), GUILayout.Height(23))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Green: ", GUILayout.Height(23)); GUILayout.FlexibleSpace(); grasColorGStr = (GUILayout.TextField(grasColorGStr, 7, GUILayout.Width(90), GUILayout.Height(23))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Blue: ", GUILayout.Height(23)); GUILayout.FlexibleSpace(); grasColorBStr = (GUILayout.TextField(grasColorBStr, 7, GUILayout.Width(90), GUILayout.Height(23))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Alpha: ", GUILayout.Height(23)); GUILayout.FlexibleSpace(); grasColorAStr = (GUILayout.TextField(grasColorAStr, 7, GUILayout.Width(80), GUILayout.Height(23))); } GUILayout.EndHorizontal(); } GUI.enabled = true; GUILayout.Space(1); GUILayout.Box(UIMain.tHorizontalSep, UIMain.BoxNoBorder, GUILayout.Height(4)); GUILayout.Label("Grass Texture: ", GUILayout.Height(23)); grasTextureName = (GUILayout.TextField(grasTextureName, 200, GUILayout.Width(280), GUILayout.Height(23))); GUILayout.Space(1); GUILayout.Box(UIMain.tHorizontalSep, UIMain.BoxNoBorder, GUILayout.Height(4)); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Apply", GUILayout.Height(23), GUILayout.Width(80))) { ApplySettings(); } } GUILayout.EndHorizontal(); GUILayout.Space(1); GUILayout.Box(UIMain.tHorizontalSep, UIMain.BoxNoBorder, GUILayout.Height(4)); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Cancel", GUILayout.Height(23))) { this.Close(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Apply & Close", GUILayout.Height(23))) { ApplySettings(); this.Close(); } } GUILayout.EndHorizontal(); GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
/// <summary> /// Saves the current instance settings to the object. /// </summary> internal void ApplySettings() { selectedInstance.Update(); UpdateGizmo(); }
/// <summary> /// Saves the current instance settings to the object. /// </summary> internal void ApplySettings() { selectedInstance.Update(); SetupFields(); }
/// <summary> /// Saves the current instance settings to the object. /// </summary> internal void ApplySettings() { selectedObject.Update(); }