/// <summary> /// Initalise everything and deligates relating to the controller input. /// </summary> void Awake() { maincon = GetComponent <MainMenuControllerController>(); SceneManager.sceneLoaded += OnLevelFinishedLoading; lefthandscriptl = GameObject.Find("LeftController").GetComponent <LeftControl_Onehanddrag>(); WorldBase = GameObject.Find("World").transform.Find("Objects").gameObject; startscale = resizeobj.transform.localScale; startpos = resizeobj.transform.position; resizing = resizeobj.GetComponent <Resizescript>(); ConeBig = transform.Find("ConeBig").gameObject; ConeBig.SetActive(false); ConeSmall = transform.Find("ConeSmall").gameObject; ConeSmall.SetActive(false); MenuObj.SetActive(false); vrtkcontrolevents = GetComponent <VRTK_ControllerEvents>(); vrtkcontrolevents.TouchpadPressed += new ControllerInteractionEventHandler(Touchpaddown); vrtkcontrolevents.TouchpadReleased += new ControllerInteractionEventHandler(Touchpadup); vrtkcontrolevents.TriggerPressed += new ControllerInteractionEventHandler(Trigger); vrtkcontrolevents.TriggerReleased += new ControllerInteractionEventHandler(TriggerUp); vrtkcontrolevents.ButtonTwoPressed += new ControllerInteractionEventHandler(Menu); vrtkcontrolevents.GripPressed += new ControllerInteractionEventHandler(grip); vrtkcontrolevents.ButtonOnePressed += new ControllerInteractionEventHandler(turnbutton); if (GetComponent <LineRenderer>() == null) { lineren = gameObject.AddComponent <LineRenderer>(); } else { lineren = GetComponent <LineRenderer>(); } lineren.material = linemat; lineren.SetPosition(0, new Vector3(0, 0, 0)); lineren.SetPosition(1, new Vector3(0, 0, 0)); }
/// <summary> /// the update to update everything relating to things like touchpad amount and the linerender positioning. /// </summary> void Update() { if (this != null && this.gameObject != null && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 0 && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 1 && SceneManager.GetActiveScene().buildIndex != 5 && SceneManager.GetActiveScene().buildIndex != 6) { revertcountdown--; if (revertcountdown == 0) { lineren.material = startmat; } if (vrtkcontrolevents == null) { vrtkcontrolevents = GetComponent <VRTK_ControllerEvents>(); } touchpadamount = vrtkcontrolevents.GetTouchpadAxis().y; if (resizing.transform.localScale.x != 1) { lineren.startWidth = 0.002f * resizing.transform.lossyScale.x; lineren.endWidth = 0.002f * resizing.transform.lossyScale.x; } resizing.speed = (lefthandscriptl.touchpadamount * 5) + 0.5f; if (triggerdown) { resizing.StickInput(transform.parent.localRotation); } if ((touchpadamount < -0.05f || touchpadamount > 0.05f) && touchpadDown == false) { if (resizing.WaspPos != null && resizing.WaspPos.GetActive() == false) { lineren.enabled = true; } } else if (maincon == null || maincon.hitobj == null) { lineren.enabled = false; } if (touchpadamount > -0.05f && touchpadamount < 0.05f && ConeSmall.GetActive() == true) { ConeSmall.SetActive(false); } if (lineren.enabled == true) { setlinerenpos(); } if (ConeSmall.GetActive() == true) { lineren.enabled = false; } } }