/// <summary> /// Place a new building at the pointed location. /// </summary> private void PlaceBuilding() { this.gameObject.AddComponent <BuildingPlane>(); MetaBody mb = this.gameObject.AddComponent <MetaBody>(); mb.maxScaleRatio = 100; this.ChangeOutlineRender(this.defaultShader); this.StateContext.SetState(new ModifyState(this.StateContext, this.gameObject)); }
/// <summary> /// Return to the modify state /// </summary> public void OnBackButton() { if (this.CanSwitchState()) { MetaBody mb = this.gameObject.GetComponent <MetaBody>(); mb.useDefaultGrabSettings = true; mb.grabbableDistance = 0.1f; mb.grabbable = false; mb.rotateObjectOnTwoHandedGrab = false; this.StateContext.SetState(new ModifyState(this.StateContext, this.gameObject)); } }
/// <summary> /// Initializes a new instance of the <see cref="ModifyScaleState"/> class. /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> /// <param name="gameObject">The game object to be scaled</param> public ModifyScaleState(StateContext stateContext, GameObject gameObject) : base(stateContext) { this.gameObject = gameObject; MetaBody mb = gameObject.GetComponent <MetaBody>(); mb.useDefaultGrabSettings = false; mb.grabbable = true; mb.moveObjectOnGrab = false; mb.grabbableDistance = float.MaxValue; mb.scaleObjectOnTwoHandedGrab = true; this.InitButton("BackButton", () => this.OnBackButton()); this.InitTextPane("InfoText", "Scale"); }
/// <summary> /// Initializes a new instance of the <see cref="ModifyRotateState"/> class. /// </summary> /// <param name="stateContext">The class that keeps track of the current active state</param> /// <param name="gameObject">The object that will be rotated</param> public ModifyRotateState(StateContext stateContext, GameObject gameObject) : base(stateContext) { this.gameObject = gameObject; MetaBody mb = gameObject.GetComponent <MetaBody>(); mb.useDefaultGrabSettings = false; mb.grabbable = true; mb.grabbableDistance = float.MaxValue; mb.moveObjectOnGrab = false; mb.rotateObjectOnTwoHandedGrab = true; this.originalOrientation = gameObject.transform.localEulerAngles; this.InitButton("BackButton", () => this.OnBackButton()); this.InitTextPane("InfoText", "Rotate"); }
public void combine() { GameObject newparent = GameObject.CreatePrimitive(PrimitiveType.Cube); foreach (Transform child in parent.transform) { child.parent = newparent.transform; MetaBody mb = child.GetComponent <MetaBody>(); if (mb) { mb.grabbable = false; mb.pinchable = false; } } newparent.transform.parent = parent.transform; newparent.AddComponent <MetaBody> (); MetaBody mb2 = newparent.GetComponent <MetaBody> (); mb2.grabbable = true; Destroy(newparent.GetComponent <MeshRenderer> ()); newparent.name = "cuuuba"; }