void Awake() { if (PaintBrush == null) { try { PaintBrush = GameObject.Find("[Paint_Brush]"); paintBrush = PaintBrush.GetComponent <A_PaintBrush>(); } catch (Exception e) { print("please attach the [Paint_Brush] object in the inspector"); }; } else { paintBrush = PaintBrush.GetComponent <A_PaintBrush>(); //get raypoint script try { ray = PaintBrush.transform.GetChild(0).GetComponent <RayPointer>(); } catch (Exception e) { print("ray pointer script doesnt exist or has been moved?"); }; } }
// So that game still works even when they are no controllers void TryInitialize() { List <InputDevice> devices = new List <InputDevice>(); InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices); foreach (var item in devices) { Debug.Log(item.name + item.characteristics); } if (devices.Count > 0) { targetDevice = devices[0]; GameObject prefab = controllerPrefabs.Find(controller => controller.name == targetDevice.name); if (prefab) { spawnedHandModel = Instantiate(prefab, transform); handAnimator = spawnedHandModel.GetComponent <Animator>(); } else { Debug.LogError("Did not find corresponding controller model"); spawnedHandModel = Instantiate(controllerPrefabs[0], transform); handAnimator = spawnedHandModel.GetComponent <Animator>(); } } if (GameObject.Find("IteratorCursor") != null) { Iterator = true; IteratorCursor = GameObject.Find("IteratorCursor"); IteratorCursorScript = IteratorCursor.GetComponent <IteratorCursor>(); } else if (GameObject.Find("DepthRay/RayCursor") != null) { DepthRay = true; RayPointer = GameObject.Find("DepthRay/RayCursor"); DepthRayScript = RayPointer.GetComponent <RayCursor>(); } //spawnedHandModel = Instantiate(controllerPrefabs[0], transform); //handAnimator = spawnedHandModel.GetComponent<Animator>(); }
//------------------------------------------------------- #endregion private void Awake() { //REFERENCES //eraser if (this.transform.GetChild(3).gameObject.GetComponent <A_Eraser>() != null) { eraser = this.transform.GetChild(3).gameObject; } else { print("Eraser object doesn't seem to exist or has been moved?"); }; //active brush try { activeBrush = paintPallete.paintBrushType; } catch (Exception e) { print("please attach the [Paint_Palette] object in the inspector"); }; //rayPointer try { ray = this.transform.GetChild(0).GetComponent <RayPointer>(); } catch (Exception e) { print("Eraser object doesn't seem to exist or has been moved?"); }; //controller try { trackedObj = VRController.GetComponent <SteamVR_TrackedObject>(); } catch (Exception e) { print("VRController object doesn't seem to exist or has been moved?"); }; //paintBrush holder paintBrushHolder = this.transform.GetChild(1).transform; //line renderer if (this.transform.GetChild(5).gameObject.GetComponent <LineRenderer>() != null) { helperLineRenderer = this.transform.GetChild(5).gameObject.GetComponent <LineRenderer>(); } else { print("Helper Line Renderer object doesn't seem to exist or has been moved?"); }; }
void Start() { //paintMaster if (paintPalette == null) { paintPalette = this.transform.parent.parent.parent.GetComponent <A_PaintPalette>(); } //get raypoint script ray = paintPalette.ray.GetComponent <RayPointer>(); //get the texture tex = (Texture2D)this.transform.GetChild(0).GetComponent <Renderer>().material.mainTexture; //color preview colorPreview = this.transform.GetChild(1).gameObject.GetComponent <Image>(); //RGB text if (RGBtext == null) { RGBtext = this.transform.GetChild(2).GetChild(2).GetComponent <Text>(); } }