public void InitializeStuff() { //Initialize Canvas items... GameObject canvas = GameObject.FindGameObjectWithTag (Tags.canvas); Text[] allText = canvas.GetComponentsInChildren<Text> (); foreach (Text txt in allText){ if(txt.tag == Tags.dialogueText){ dialogueTextField = txt; } else if(txt.tag == Tags.characterNameText){ characterNameText = txt; } } Scrollbar[] allScrollBars = canvas.GetComponentsInChildren<Scrollbar> (); foreach (Scrollbar sb in allScrollBars){ if(sb.tag == Tags.scrollBar){ scrollBar = sb; } } //Initialize particle system for Interaction Indicator... indicatorParticleSystem = GetComponentInChildren<ParticleSystem> (); cursorGO = GameObject.FindGameObjectWithTag (Tags.cursor); //Initialize interaction collider on awake... col = GetComponent<SphereCollider>(); SetColliderPosition (); //Parse the text file into the array, dialogueTextParsed... dialogueTextParsed = dialogueText.text.Split('\n'); if(messageIsUrgent && !noMessageJustMove){ indicatorParticleSystem.Play (); } playerTransform = GameObject.FindGameObjectWithTag (Tags.player).transform; playerRB = playerTransform.GetComponent<Rigidbody>(); //Initialize NPC NavMeshAgent and EnemyAI... nav = gameObject.GetComponentInParent<NavMeshAgent> (); enemyAI = gameObject.GetComponentInParent<EnemyAI> (); //Get interaction rate from Player.. interactionRate = GameObject.FindGameObjectWithTag (Tags.player).GetComponent<PlayerInteraction> ().interactionRate; //Get animator info... animatorArrayNPC = transform.parent.GetComponentsInChildren<Animator> (); //Initialize dialoguePanelOpenClose... dialoguePanelOpenClose = canvas.GetComponentInChildren<DialoguePanelOpenClose> (); }
public void InitializeStuff() { //Initialize Canvas items... GameObject canvas = GameObject.FindGameObjectWithTag (Tags.canvas); Text[] allText = canvas.GetComponentsInChildren<Text> (); foreach (Text txt in allText){ if(txt.tag == Tags.dialogueText){ dialogueTextField = txt; } else if(txt.tag == Tags.characterNameText){ characterNameText = txt; } } Scrollbar[] allScrollBars = canvas.GetComponentsInChildren<Scrollbar> (); foreach (Scrollbar sb in allScrollBars){ if(sb.tag == Tags.scrollBar){ scrollBar = sb; } } //Initialize particle system for Interaction Indicator... indicatorParticleSystem = GetComponentInChildren<ParticleSystem> (); cursorGO = GameObject.FindGameObjectWithTag (Tags.cursor); //Parse the text file into the array, dialogueTextParsed... dialogueTextParsed = dialogueText.text.Split('\n'); if(hasParticleSystemIndicator && playParticleSystemIndicatorBeforeEnabled){ indicatorParticleSystem.Play (); } if(!noPlayerInScene){ GameObject playerGO = GameObject.FindGameObjectWithTag(Tags.player); playerTransform = playerGO.transform; playerRB = playerTransform.GetComponent<Rigidbody>(); //Get interaction rate from Player.. interactionRate = playerGO.GetComponent<PlayerInteraction> ().interactionRate; } else{ //if no player in scene, then the camera cannot target the player... cameraTargetPlayer = false; } //Initialize dialoguePanelOpenClose... dialoguePanelOpenClose = canvas.GetComponentInChildren<DialoguePanelOpenClose> (); }