public virtual void Tick(float elapse) { if (this.next != null) { if (this.current != null) { this.current.Quit(); } this.current = this.next; this.next = null; XCSharp.InvokeAction(this.onChangeState, this.last, this.current); if (this.current != null) { this.current.Init(this); } } else { if (this.current != null) { this.current.Update(elapse); } } }
public void LoadPrefabAsync(string bundleName, string prefabName, System.Action <GameObject> handler) { if (string.IsNullOrEmpty(bundleName) || string.IsNullOrEmpty(prefabName)) { XCSharp.InvokeAction(handler, null); return; } this.LoadAssetAsync <GameObject>(bundleName, "Prefabs/" + prefabName, handler); }
public void LoadAssetAsync <T>(string bundleName, string location, System.Action <T> handler) where T : Object { if (string.IsNullOrEmpty(bundleName) || string.IsNullOrEmpty(location)) { Debug.LogError("LoadAssetAsync: bundle name or location is null or empty. bundle=" + bundleName + "\n location=" + location); XCSharp.InvokeAction(handler, null); return; } this.StartCoroutine(this.CreateAssetAsync <T>(bundleName, location, handler)); }
public virtual void Close() { if (this.destroyOnClose) { Object.Destroy(this.gameObject); } else { this.gameObject.SetActive(false); } XCSharp.InvokeAction(this.onClose); }
private IEnumerator CreateSceneAsync(string sceneName, System.Action <string> handler = null) { this.mIsLoadingScene = true; this.mLoadingSceneName = sceneName; string bundleName = this.GetBundleNameFromLevelName(sceneName); if (string.IsNullOrEmpty(bundleName)) { var oper = SceneManager.LoadSceneAsync(sceneName); yield return(oper); } else { AssetBundle bundle = mBundleCache.Get(bundleName); if (bundle == null) { BundleLoading loading = new BundleLoading(); yield return(this.StartCoroutine(loading.LoadAsync(bundleName))); if (!string.IsNullOrEmpty(loading.error)) { Debug.LogError(loading.error); this.mIsLoadingScene = false; XCSharp.InvokeAction(handler, ""); yield break; } bundle = loading.bundle; } if (bundle == null) { this.mIsLoadingScene = false; XCSharp.InvokeAction(handler, ""); yield break; } var oper = SceneManager.LoadSceneAsync(sceneName); yield return(oper); if (bundle != null) { bundle.Unload(false); } } this.mIsLoadingScene = false; XCSharp.InvokeAction(handler, sceneName); }
public void LoadAssetAsync <T>(string path, System.Action <T> handler) where T : Object { int index = path.IndexOf('/'); if (index <= 0 || index >= path.Length - 1) { XCSharp.InvokeAction(handler, null); return; } string bundleName = path.Substring(0, index); string location = path.Substring(index + 1); this.LoadAssetAsync <T>(bundleName, location, handler); }
void Awake() { // register messages XCSharp.InvokeAction(this.onRegisterMessages, this); // register recv-callback this.mClient.OnConnSuccess += this.OnConnSuccess; this.mClient.OnConnFailure += this.OnConnFailure; this.mClient.OnSendSuccess += this.OnSendSuccess; this.mClient.OnSendFailure += this.OnSendFailure; this.mClient.OnSendRawdata += this.OnSendRawdata; this.mClient.OnSendMessage += this.OnSendMessage; this.mClient.OnRecvSuccess += this.OnRecvSuccess; this.mClient.OnRecvFailure += this.OnRecvFailure; this.mClient.OnRecvRawdata += this.OnRecvRawdata; this.mClient.OnRecvMessage += this.OnRecvMessage; }
public void AcquireGameObjectAsync(string bundleName, string prefabName, System.Action <GameObject> handler) { GameObject go = mGameObjectPool.Pop(bundleName, prefabName); if (go != null) { go.SetActive(true); XCSharp.InvokeAction(handler, go); return; } this.LoadPrefabAsync(bundleName, prefabName, prefab => { if (prefab == null) { XCSharp.InvokeAction(handler, null); return; } GameObject result = Object.Instantiate(prefab) as GameObject; XCSharp.InvokeAction(handler, result); }); }
private IEnumerator CreateAssetAsync <T>(string bundleName, string location, System.Action <T> handler) where T : Object { // get from cache { T asset = mAssetCache.Get <T>(bundleName, location); if (asset != null) { XCSharp.InvokeAction(handler, asset); yield break; } } // async begins if (mAssetWaitings.Wait(bundleName, location, handler)) { yield break; } string assetPath = bundleName + "/" + location; var req = Resources.LoadAsync <T>(assetPath); yield return(req); if (req.asset != null) { mAssetCache.Put(bundleName, location, req.asset); mAssetWaitings.Notify(location, req.asset as T); yield break; } AssetBundle bundle = mBundleCache.Get(bundleName); if (bundle == null) { BundleLoading loading = mBundleLoader.GetBundleAsyncLoading(bundleName); if (loading != null) { while (!loading.done) { yield return(null); } bundle = loading.bundle; } else { loading = mBundleLoader.NewBundleAsyncLoading(bundleName); yield return(this.StartCoroutine(loading.LoadAsync(bundleName))); if (!string.IsNullOrEmpty(loading.error)) { mAssetWaitings.Notify(location, null as T); yield break; } bundle = loading.bundle; if (bundle != null) { mBundleCache.Put(bundleName, bundle); } } mBundleLoader.RemoveBundleAsyncLoading(bundleName); } if (bundle == null) { mAssetWaitings.Notify(location, null as T); yield break; } { string assetName = System.IO.Path.GetFileName(location); var request = bundle.LoadAssetAsync <T>(assetName); yield return(request); // check if the bundle is destroyed by extern code. if (bundle == null) { mAssetWaitings.Notify(location, null as T); yield break; } // get asset now. if (request.asset != null) { mAssetCache.Put(bundleName, location, request.asset); } mAssetWaitings.Notify(location, request.asset as T); } }
void OnMoveAnyWhere(InputTouch touch) { if (this.mPressTouch == null || touch.fingerId != this.mPressTouch.fingerId) { return; } RaycastHit hit; if (this.TouchOnColliders(this.mPressTouch, touch, out hit)) { Vector3 point = this.transform.InverseTransformPoint(hit.point); Vector3 delta = point - this.mLastPoint; if (this.Approximately(delta, Vector3.zero)) { return; } this.mPressDelta += delta; if (this.mPressItem != null && this.mPressItem.canBeDragOut && touch.target != null && touch.target == this.mPressItem.inputTarget) { float sqrd = this.mPressDelta.sqrMagnitude; float angle = Vector3.Angle(this.mPressDelta, this.mDirection); if (sqrd > this.dragOut * this.dragOut && angle > 45 && angle < 135) { XCSharp.InvokeAction(this.onDragOut, this, this.mPressItem); if (this.mPressItem.removeWhenDragOut) { this.Remove(this.mPressItem); } this.mPressTouch = null; this.mPressItem = null; return; } } delta = this.ShadowOnNomalized(delta, this.mDirection); delta = this.AdjustDeltaInRange(delta); this.mLastPoint = point; this.mLastDelta = delta; this.mDestination += delta; this.mNeedUpdate = true; } else { if (this.mPressItem != null && this.mPressItem.canBeDragOut) { XCSharp.InvokeAction(this.onDragOut, this, this.mPressItem); if (this.mPressItem.removeWhenDragOut) { this.Remove(this.mPressItem); } this.mPressTouch = null; this.mPressItem = null; } } }
void OnCollisionEnter(Collision collision) { XCSharp.InvokeAction(this.onCollisionEnter, collision); }
void OnDestroy() { XCSharp.InvokeAction(this.onDestroy); }
void OnPress(InputTouch touch) { XCSharp.InvokeAction(this.onPress, touch, this); }
void OnParticleCollision(GameObject other) { XCSharp.InvokeAction(this.onParticleCollision, other); }
void OnTriggerStay(Collider c) { XCSharp.InvokeAction(this.onTriggerStay, c); }
void OnTriggerExit(Collider c) { XCSharp.InvokeAction(this.onTriggerExit, c); }
void OnTriggerEnter(Collider c) { XCSharp.InvokeAction(this.onTriggerEnter, c); }
void OnCollisionStay(Collision collision) { XCSharp.InvokeAction(this.onCollisionStay, collision); }
void OnCollisionExit(Collision collision) { XCSharp.InvokeAction(this.onCollisionExit, collision); }
void OnEnable() { XCSharp.InvokeAction(this.onEnable); }
public virtual void Open() { XCSharp.InvokeAction(this.onOpen); this.gameObject.SetActive(true); }
void Update() { XCSharp.InvokeAction(this.onUpdate); }
void Awake() { XCSharp.InvokeAction(this.onAwake); }
void OnDisable() { XCSharp.InvokeAction(this.onDisable); }
void OnClick(InputTouch touch) { XCSharp.InvokeAction(this.onClick, touch, this); }
void OnPressItem(InputTouch touch, DragListItem item) { this.mPressItem = item; XCSharp.InvokeAction(this.onPressItem, this, item); }
void OnClickItem(InputTouch touch, DragListItem item) { XCSharp.InvokeAction(this.onClickItem, this, item); }
void Start() { XCSharp.InvokeAction(this.onStart); }