void ClearEvent() { if (CCDefine.USE_KEYBOARD) { CCApp.UnschOnGUI(Step); //键盘事件需要监听gui更新 } }
void SetupEvent() { if (CCDefine.USE_KEYBOARD) { CCApp.SchOnGUI(Step); //键盘事件需要监听gui更新 } }
private void SetupEvent() { if (m_isAutoUpdate) { CCApp.SchUpdate(Step); } }
void Update() { CCApp.Step(Time.deltaTime); if (OnUpdate != null) { OnUpdate(Time.deltaTime); } }
protected void SchUpdate(bool b_) { if (m_isSchUpdte == b_) { return; } m_isSchUpdte = b_; CCApp.SchUpdateOrNot(Step, b_); }
protected void UnscheduleUpdate() { if (!m_schUpdated) { return; } m_schUpdated = false; CCApp.UnschUpdate(Step); }
void LateUpdate() { CCApp.LateStep(Time.deltaTime); if (OnLateUpdate != null) { OnLateUpdate(Time.deltaTime); } }
//-------∽-★-∽------∽-★-∽--------∽-★-∽Schedule∽-★-∽--------∽-★-∽------∽-★-∽--------// protected void ScheduleUpdate() { if (m_schUpdated) { return; } m_schUpdated = true; CCApp.SchUpdate(Step); }
//-------∽-★-∽------∽-★-∽--------∽-★-∽数据操作∽-★-∽--------∽-★-∽------∽-★-∽--------// public void Start() { if (m_running) { return; } m_running = true; if (m_isAutoUpdate) { CCApp.SchUpdate(Step); } }
public void Stop() { if (!m_running) { return; } m_running = false; if (m_isAutoUpdate) { CCApp.UnschUpdate(Step); } }
/// <summary> /// 异步加载 /// </summary> /// <param name="url_"></param> /// <param name="isAdditive"></param> /// <param name="onComplete_"></param> /// <param name="refer_">只用于onComplete_</param> /// <returns></returns> public LevelData LoadAsync(string url_, bool isAdditive, CALLBACK_1 onComplete_, object refer_) { url_ = url_.ToLower(); LevelData data = GetData(url_); if (data != null) { if (data.isLoading) { if (onComplete_ != null) { Attach(url_, onComplete_, refer_); } return(data); } if (data.isComplete) { if (onComplete_ != null) { onComplete_(data); } return(data); } } if (!isAdditive) { TransSceneBegin(); //转场 } if (onComplete_ != null) { Attach(url_, onComplete_, refer_); } data = CreateData(url_, isAdditive); data.isLoading = true; data.isComplete = false; data.enumerator = __LoadAsync(data); CCApp.StartCoroutine(data.enumerator); return(m_url2data[url_]); }
/// <summary> /// 异步加载 /// </summary> /// <param name="refer_"></param> /// <param name="url_"></param> /// <param name="onComplete_"></param> /// <returns></returns> override public AssetData LoadAsync(string url_, CALLBACK_1 onComplete_, object refer_) { url_ = url_.ToLower(); AssetData data = CreateData(url_); //先创建data, 用以记录生命周期等 data.Retain(refer_); if (data.asset != null) { //加载完成 if (onComplete_ != null) { onComplete_(data); } return(data); } if (m_url2req.ContainsKey(data.url)) { //加载中 if (onComplete_ != null) { Attach(data.url, onComplete_, refer_); } return(data); } //未启动加载, 至少保持一个引用 data.Retain(this); if (onComplete_ != null) { Attach(data.url, onComplete_, refer_); } CCApp.StartCoroutine(__LoadAsync(data.url)); return(data); }
private void ClearEvent() { CCApp.UnschUpdate(Step); }
//实际监听update, 默认监听CCApp, 可根据需要重写 virtual protected void __SchUpdate() { CCApp.SchUpdate(Step); }
private void SetupEvent() { CCApp.SchUpdate(Step); }
//void FixedUpdate() //{ // CCApp.FixedStep(Time.fixedDeltaTime); //} //物体启用时被调用 //void OnEnable() { } //物体被禁用时调用 //void OnDisable() { } //void OnDestroy() //{ //物体被删除时调用 //CCApp.Clear(); //} void OnApplicationQuit() { CCApp.OnAppQuit(); }
//当一个脚本实例被载入时Awake被调用,要先于Start //this.gameObject.GetComponent<Transform>().position = new Vector3(); //this.transform.parent = null; //void Awake() { } //Start仅在Update函数第一次被调用前调用 //void Start() { } //Reset是在用户点击检视面板的Reset按钮或者首次添加该组件时被调用.此函数只在编辑模式下被调用. //Reset最常用于在检视面板中给定一个最常用的默认值. //void Reset() { } void OnGUI() { CCApp.OnGUI(Time.deltaTime); }
virtual protected void __UnschUpdate() { CCApp.UnschUpdate(Step); }
IEnumerator __LoadAsync(LevelData data) { string url_ = data.url; bool isAdditive = data.isAdditive; LoadSceneMode mode = isAdditive ? LoadSceneMode.Additive : LoadSceneMode.Single; AsyncOperation op; float progress = 0f; float weight = 0.1f; if (!isAdditive) { op = SceneManager.LoadSceneAsync(LEVEL_NAME_EMPTY, mode); while (!op.isDone) { data._progress = progress + weight * op.progress; yield return(null); } //Log.Debug("空场景加载完成:" + LEVEL_NAME_EMPTY, this); yield return(new WaitForSeconds(0.1f)); //等一会儿 } progress += weight; weight = 0.2f; AssetData assetData = AssetCache.me.LoadAsync_Level(url_, null, this); //先加载此场景所需的资源 if (assetData != null) { while (!assetData.isDone) { data._progress = progress + weight * assetData.progress; yield return(null); } } progress += weight; weight = 0.7f; op = SceneManager.LoadSceneAsync(data.url, mode); if (op == null) { //Log.Assert("x level load fail: " + url_, this); CCApp.StopCoroutine(data.enumerator); data.enumerator = null; LuaEvtCenter.AddEvent(RES_EVT.LOAD_LEVEL_EXCEPTION, data.url); yield return(0); } Log.Info("☆ load level async start: " + url_, this); while (!op.isDone) { data._progress = progress + weight * op.progress; yield return(null); } Log.Info("★ load level async success: " + url_, this); LevelData data2 = GetData(url_); if (data2 != null) { if (data == data2) { data.__OnComplete(); if (!isAdditive) { TransSceneFinsh(); } Notify(url_, data); LuaEvtCenter.AddEvent(RES_EVT.LOAD_LEVEL_COMPLETE, data); } else { //启动了异步, 同时又启动同步 data.__OnComplete(); Notify(url_, data); LuaEvtCenter.AddEvent(RES_EVT.LOAD_LEVEL_COMPLETE, data); } } else { //已销毁 } data.enumerator = null; DetachByType(url_); }