/// <summary> /// Create all necessary resources. /// </summary> private void SetupManipulation() { TakeDownManipulation(); if (userOriented) { boundingBox = owner.gameObject.AddComponent <BoundingBox>(); boundingBox.HideElementsInInspector = false; boundingBox.BoundingBoxActivation = BoundingBox.BoundingBoxActivationType.ActivateByProximityAndPointer; boundingBox.RotateStarted.AddListener(BeginManipulation); boundingBox.RotateStopped.AddListener(FinishManipulation); boundingBox.ScaleStarted.AddListener(BeginManipulation); boundingBox.ScaleStopped.AddListener(FinishManipulation); float maxScaleFactor = 8.0f; float minScaleFactor = 0.2f; TransformScaleHandler scaleHandler = owner.GetComponent <TransformScaleHandler>(); if (scaleHandler == null) { scaleHandler = owner.gameObject.AddComponent <TransformScaleHandler>(); } scaleHandler.RelativeToInitialState = true; scaleHandler.ScaleMaximum = maxScaleFactor; scaleHandler.ScaleMinimum = minScaleFactor; } manipulationHandler = owner.gameObject.AddComponent <ManipulationHandler>(); manipulationHandler.OneHandRotationModeFar = ManipulationHandler.RotateInOneHandType.MaintainOriginalRotation; manipulationHandler.OneHandRotationModeNear = ManipulationHandler.RotateInOneHandType.MaintainOriginalRotation; manipulationHandler.ConstraintOnRotation = Toolkit.Utilities.RotationConstraintType.None; manipulationHandler.OnManipulationStarted.AddListener(BeginManipulation); manipulationHandler.OnManipulationEnded.AddListener(FinishManipulation); nearGrabbable = owner.gameObject.AddComponent <NearInteractionGrabbable>(); }
void Start() { scaleMaximum = transform.localScale.x * 7 / 6; scaleMinimum = scaleMaximum * 2 / 7; transformScaleHandler = this.GetComponent <TransformScaleHandler>() as TransformScaleHandler; transformScaleHandler.ScaleMinimum = scaleMinimum; transformScaleHandler.ScaleMaximum = scaleMaximum; output = GameObject.FindGameObjectWithTag("OSCHandler").GetComponent <OSCOutput>(); toolTip = this.transform.GetChild(0).gameObject.GetComponent <ToolTip>(); toolTip.ToolTipText = (id + 1).ToString(); radShell = Mathf.Sqrt(transform.position.x * transform.position.x + transform.position.y * transform.position.y + transform.position.z * transform.position.z); matDefault = Resources.Load("yellow") as Material; matMin = Resources.Load("blue") as Material; setDefaultMat(); }