123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
-
- namespace NRKernal
- {
- using UnityEngine;
-
-
- [HelpURL("https://developer.nreal.ai/develop/discover/introduction-nrsdk")]
- [ScriptOrder(NativeConstants.NRSESSIONBEHAVIOUR_ORDER)]
- public class NRSessionBehaviour : SingletonBehaviour<NRSessionBehaviour>
- {
-
- [Tooltip("LogLevel of NRSDK.")]
- [SerializeField]
- LogLevel LogLevel = LogLevel.Info;
-
- [Tooltip("A scriptable object specifying the NRSDK session configuration.")]
- [SerializeField]
- public NRSessionConfig SessionConfig;
-
-
-
-
- new void Awake()
- {
- #if NRDEBUG
- NRDebugger.logLevel = LogLevel.All;
- #elif !UNITY_EDITOR
- NRDebugger.logLevel = Debug.isDebugBuild ? LogLevel.Debug : LogLevel;
- #else
- NRDebugger.logLevel = LogLevel;
- #endif
-
- base.Awake();
- if (isDirty) return;
- NRDebugger.Info("[SessionBehaviour] Awake: CreateSession");
- NRSessionManager.Instance.CreateSession(this);
- }
-
- void Start()
- {
- if (isDirty) return;
- NRDebugger.Info("[SessionBehaviour] Start: StartSession");
- NRSessionManager.Instance.StartSession();
- }
-
-
- private void OnApplicationPause(bool pause)
- {
- if (isDirty) return;
- NRDebugger.Info("[SessionBehaviour] OnApplicationPause: {0}", pause);
- if (pause)
- {
- NRSessionManager.Instance.DisableSession();
- }
- else
- {
- NRSessionManager.Instance.ResumeSession();
- }
- }
-
- void OnEnable()
- {
- if (isDirty) return;
- NRDebugger.Info("[SessionBehaviour] OnEnable: ResumeSession");
- NRSessionManager.Instance.ResumeSession();
- }
-
- void OnDisable()
- {
- if (isDirty) return;
- NRDebugger.Info("[SessionBehaviour] OnDisable: DisableSession");
- NRSessionManager.Instance.DisableSession();
- }
-
-
-
-
- new void OnDestroy()
- {
- if (isDirty) return;
- base.OnDestroy();
- NRDebugger.Info("[SessionBehaviour] OnDestroy: DestroySession");
- NRSessionManager.Instance.DestroySession();
- }
- }
- }
|