GameMain.cs 807 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityGameFramework.Runtime;
  5. public partial class GameMain : MonoBehaviour
  6. {
  7. float heartInterval = 60;
  8. public static bool beginHeart = false;
  9. void Start()
  10. {
  11. DontDestroyOnLoad(this);
  12. InitBuiltinComponents();
  13. InitCustomComponents();
  14. //广播事件样例
  15. Log.Debug("广播GameMainComponentLoadDoneEvent事件");
  16. Event.Fire(this,GameMainComponentLoadDoneEvent.Create());
  17. }
  18. private void Update()
  19. {
  20. if (beginHeart)
  21. {
  22. heartInterval -= Time.deltaTime;
  23. if (heartInterval < 0)
  24. {
  25. heartInterval = 60;
  26. HttpGlobal.SendPingToServer();
  27. }
  28. }
  29. }
  30. }