SceneEventBubbleCmptLogic.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityGameFramework.Runtime;
  6. public class SceneEventBubbleCmptLogic : MonoBehaviour
  7. {
  8. Button btnInteractive;
  9. private void Awake()
  10. {
  11. }
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. SceneEventOpenBox info = this.gameObject.GetComponent<SceneEventOpenBox>();
  16. }
  17. public void OnTriggerEnter(Collider collider)
  18. {
  19. if(collider.gameObject.layer != LayerMask.NameToLayer("Player"))
  20. {
  21. return;
  22. }
  23. ResourceHelper.Instance.LoadAssetBundle("SceneBubbleWindow", ab =>
  24. {
  25. if (ab != null)
  26. {
  27. GameObject bubble = (GameObject)GameObject.Instantiate(ab.LoadAsset("SceneBubbleWindow"));
  28. bubble.transform.SetParent(this.transform);
  29. bubble.transform.localPosition = Vector3.zero;
  30. bubble.transform.SetLocalPositionY(2.0f);
  31. SceneCmptBubbleWindow buCmpt = bubble.AddComponent<SceneCmptBubbleWindow>();
  32. TransformRotation rtCmpt = bubble.AddComponent<TransformRotation>();
  33. buCmpt.SetContent("Test");
  34. }
  35. });
  36. }
  37. public void OnTriggerExit(Collider collider)
  38. {
  39. btnInteractive.gameObject.SetActive(false);
  40. }
  41. public void EnableCollider()
  42. {
  43. }
  44. }