private void Start() { //this.name = this.gameObject.GetInstanceID().ToString(); spriterEnabled = false; if (boundsType == BoundsType.StaticBox) { staticBoxBounds = this.GetComponentInChildren <BoxCollider>(); } playerCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); spriteWriteManager = GameObject.FindObjectOfType <SpriteWriteManager>(); spriteCamera = this.GetComponentInChildren <Camera>(); spriteCameraPivot = this.transform.Find("SpriteCameraPivot").gameObject; spriteOrigin = this.transform.Find("SpriteOrigin").gameObject; spriteObj = this.transform.Find("SpriteOrigin/SpriteObject").gameObject; BasePlane = this.transform.Find("BasePlane").transform; spriteMaterial = spriteObj.gameObject.GetComponent <Renderer>().material; billBoardFace = spriteOrigin.GetComponent <BillboardFace>(); _renderer = spriteObj.GetComponent <Renderer>(); _propBlock = new MaterialPropertyBlock(); //Baseplane need not be renderered in game since it is only for positional reference. BasePlane.GetComponent <Renderer>().enabled = false; rT = new RenderTexture(32, 32, 0); rT.useMipMap = true; rT.autoGenerateMips = true; if (UMACharacter) { StartCoroutine(DelayGetRenderers()); } else { //GetRenderers(); //Invoke("GetRenderers", 0); GetRenderers(); GetBounds(); subjectOrientation = this.transform.eulerAngles; spriteCamera.targetTexture = rT; spriteMaterial.mainTexture = rT; frameClock = 0.0f; frameClockOn = true; allowUpdate = true; farClipCameraPlane = spriteCamera.farClipPlane; spriterEnabled = true; UpdateQualitySettings(); } rB.WakeUp(); }
private void Awake() { #region Singleton Stuff if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; _instance.name = "SpriteWriteManager"; } #endregion //To avoid null reference exceptions, if the user didn't specify a camera, use the MainCamera. if (mainCamera == null) { mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); } #region More Culling Mask Stuff //Store the original culling mask. We will modify this by adding or subtracting // values from it to enable/disable the three Sprite Write layers. initialCullingMask = mainCamera.cullingMask; //The culling mask int is much easier to work with as binary representation: initialCullingMaskString = Convert.ToString(initialCullingMask, 2); initialCullingMaskLength = initialCullingMaskString.Length; //Initiate our change to this culling mask to be zero. changeLayers = 0; //Pass the three Sprite Write culling masks into a function to get their values. //Add or subtract from the initial culling mask to toggle them on/off as needed. toggleLayerMask("3D Model"); toggleLayerMask("2D Model"); toggleLayerMask("Invisible"); #endregion }