//===================================================== #region Private Methods void Awake() { _thisTransform = this.transform; _canvas = _thisTransform.FindChild("Canvas").GetComponent <Canvas>(); if (_canvas != null) { _cameraFacingBillboard = _canvas.GetComponent <CameraFacingBillboard>(); var button = _canvas.GetComponentInChildren <Button>(); if (button != null) { _animator = button.GetComponent <Animator>(); var image = button.transform.FindChild("Image"); _emoticon = image.GetComponent <Image>(); } } _parentNPC = _thisTransform.parent.GetComponent <NPC>(); if (_parentNPC != null) { if (_parentNPC.Type == eNPC.NPC_STUDENT) { var skinRenderers = _parentNPC.GetComponentsInChildren <Renderer>(); if (skinRenderers.Length > 0) { foreach (var skinRenderer in skinRenderers) { if (skinRenderer.name.Contains("Skin") == false) { continue; } _parentRenderer = skinRenderer; } } } else { var teachers = _parentNPC.transform.FindChild("Teachers"); if (teachers != null) { _parentRenderer = teachers.GetComponentInChildren <Renderer>(); } } if (_parentRenderer == null) { Debug.Log("Parent renderer not found"); } } _isEnabled = false; _isRewardAvailable = false; _layerCollidable = 1 << LayerMask.NameToLayer("Collidable"); }
void OnTriggerEnter(Collider other) { if (other.CompareTag("SandToy")) { audioData.Play(0); //Access the emotionholder of the player by getting the "EmotionHolder" child of the colliding body's parent emotionHolder = other.gameObject.transform.parent.GetChild(1); //Destroy previously attached emotion foreach (Transform child in emotionHolder) { GameObject.Destroy(child.gameObject); } //Attach a new Emotion GameObject ThoughtBubble = Instantiate(TearsOfJoy, other.gameObject.transform.position, Quaternion.identity, emotionHolder); //Make the Emoji follow the colliding sandtoy BubbleFollow MyBubbleFollow = ThoughtBubble.GetComponent <BubbleFollow>(); MyBubbleFollow.followTarget = other.gameObject.transform; //Make the Emoji face the assigned camera CameraFacingBillboard MyBillboardScript = ThoughtBubble.GetComponent <CameraFacingBillboard>(); MyBillboardScript.facingCamera = assignCamera; //firework.GetComponent<ParticleSystem>().Play(); //this.GetComponent<AudioSource>().Play(); } }
// Use this for initialization void Start() { _info = gameObject.transform.FindChild("Info").gameObject; _info.SetActive(false); CameraFacingBillboard bc = _info.AddComponent <CameraFacingBillboard>(); bc.autoInit = true; }