public Material playMaterial; // The play material of the band private void Awake() { // Initialized private variables and set it to the third position on the wrist DMS = dummyManager.GetComponent <DummyManagerScript>(); base.InitializeBand(); meshRenderer = transform.GetChild(0).gameObject.GetComponent <Renderer>(); meshRenderer.material = pauseMaterial; base.SetPosition(2); toggleAnimationLength = GetComponent <Animator>().runtimeAnimatorController.animationClips[2].length; toggleState = ToggleState.Pause; }
protected virtual void Awake() { DMS = dummyManager.GetComponent <DummyManagerScript>(); m_anchorOffsetPosition = transform.localPosition; m_anchorOffsetRotation = transform.localRotation; // If we are being used with an OVRCameraRig, let it drive input updates, which may come from Update or FixedUpdate. OVRCameraRig rig = null; if (transform.parent != null && transform.parent.parent != null) { rig = transform.parent.parent.GetComponent <OVRCameraRig>(); } if (rig != null) { rig.UpdatedAnchors += (r) => { OnUpdatedAnchors(); }; operatingWithoutOVRCameraRig = false; } }
public GameObject dummyIndicator; // The dummy indicator game object private void Awake() { // Initialize all private scripts speedBandScript = speedBand.GetComponent <SpeedBandScript>(); playBandScript = playBand.GetComponent <PlayBandScript>(); undoBandScript = undoBand.GetComponent <UndoBandScript>(); sliderFieldScript = sliderField.GetComponent <SliderFieldScript>(); leftGloveScript = leftGlove.GetComponent <GloveScript>(); refineGuideScript = refineGuide.GetComponent <RefineGuideScript>(); leftOVRGrabberScript = leftHandAnchor.GetComponent <OVRGrabber>(); rightOVRGrabberScript = rightHandAnchor.GetComponent <OVRGrabber>(); // Create arrays based on number of dummies in the scene dummies = GameObject.FindGameObjectsWithTag("Dummy"); startAids = new GameObject[dummies.Length]; endAids = new GameObject[dummies.Length]; ghosts = new GameObject[dummies.Length]; for (int i = 0; i < dummies.Length; i++) { DummyManagerScript DMS = gameObject.GetComponent <DummyManagerScript>(); // Instantiate aids and ghosts GameObject dummy = dummies[i]; GameObject startAid = Instantiate(dummy); GameObject endAid = Instantiate(dummy); GameObject ghost = Instantiate(dummy); float newScalar = dummy.transform.localScale.x * 0.999f; // Prevents mesh clashing when overlaid Vector3 newLocalScale = new Vector3(newScalar, newScalar, newScalar); // Add components to each dummy dummy.AddComponent <DummyScript>(); sampleCount = (int)Mathf.Ceil(animationSeconds / speedBandScript.GetSampleRate()); // Ceil to make a nice, even number dummy.GetComponent <DummyScript>().Initialize(ref DMS, sampleCount); dummy.AddComponent <Rigidbody>(); dummy.GetComponent <Rigidbody>().useGravity = false; dummy.GetComponent <Rigidbody>().isKinematic = true; dummy.AddComponent <BoxCollider>(); // Edit start aid components startAid.name = dummy.name + "StartAid"; startAid.transform.localScale = newLocalScale; startAid.GetComponent <Renderer>().material = startAidMaterial; startAids[i] = startAid; // Edit end aid components endAid.name = dummy.name + "EndAid"; endAid.transform.localScale = newLocalScale; endAid.GetComponent <Renderer>().material = endAidMaterial; endAids[i] = endAid; // Edit ghost components ghost.AddComponent <GhostScript>(); ghost.GetComponent <GhostScript>().Initialize(ref DMS, ref sliderFieldScript, ref speedBandScript, i); ghost.name = dummy.name + "Ghost"; ghost.transform.localScale = newLocalScale; ghost.GetComponent <Renderer>().material = ghostMaterial; ghosts[i] = ghost; } // Set the selected dummy to the first dummy found, add the OVRGrabble script (so only the selected dummy can be grabbed), // and parent dummy indicator with the selected dummy and place it above the dummy selectedDummyIndex = 0; dummies[selectedDummyIndex].AddComponent <OVRGrabbable>(); dummyIndicator.transform.localScale = new Vector3(4.0f, 4.0f, 4.0f); dummyIndicator.transform.parent = dummies[selectedDummyIndex].transform; dummyIndicator.transform.localPosition = new Vector3(0.0f, (dummies[selectedDummyIndex].GetComponent <BoxCollider>().size.y / 2.0f) + dummyIndicatorOffset, 0.0f); dummyIndicator.transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f); }