void Start() { if (diagUI == null) { diagUI = GameObject.Find("LocalDataSingleton").transform.GetComponentInChildren <exampleUI>(); } }
public void TryInteract() { if (theOnlyHero == null) { theOnlyHero = GameObject.FindGameObjectWithTag("Player").GetComponent <HeroesMovement>(); } if (diagUI == null) { diagUI = GameObject.Find("LocalDataSingleton").transform.GetComponentInChildren <exampleUI>(); } Vector2 choosenOne = GeneralDir == Vector2.zero ? GameObject.FindGameObjectWithTag("Player").GetComponent <HeroesMovement>().directionOfHero : GeneralDir; RaycastHit2D rHit = Physics2D.Raycast((Vector2)theOnlyHero.transform.position + choosenOne, choosenOne, 1.0f); if (rHit.collider != null) { //In this example, we will try to interact with any collider the raycast finds //Lets grab the NPC's DialogueAssign script... if there's any VIDE_Assign assigned; if (rHit.collider.GetComponent <VIDE_Assign>() != null) { assigned = rHit.collider.GetComponent <VIDE_Assign>(); } else { return; } if (!diagUI.dialogue.isLoaded) { //... and use it to begin the conversation diagUI.Begin(assigned); LocalDataSingleton.instance.talking = true; } else { //If conversation already began, let's just progress through it diagUI.NextNode(); } //#if UNITY_ANDROID // if (rHit.collider.GetComponent<minUIExample>() != null && !LocalDataSingleton.instance.talking) // { // LocalDataSingleton.instance.talking = true; // rHit.collider.GetComponent<minUIExample>().dialogue.BeginDialogue(rHit.collider.GetComponent <VIDE_Assign>()); // Debug.Log("AC"); // } //#endif } }