private void completeHandle(SAEventX e) { isLoaded = true; AssetResource resource = e.target as AssetResource; AssetsManager.bindEventHandle(resource, completeHandle, false); if (e.type == SAEventX.FAILED) { return; } if (gameObject.activeSelf == false) { recycle(); return; } AudioClip clip = resource.data as AudioClip; if (clip != null) { _source.clip = clip; _source.loop = loop; _source.volume = _soundValue; _source.Play(); if (loop == false) { CallLater.Add(recycle, _source.clip.length); } } }
public bool dispatchEvent(SAEventX e) { if (e == null) { return(false); } if (mEventListeners == null || mEventListeners.ContainsKey(e.type) == false) { return(false); } //不太明白下面几行的用意 IEventDispatcher previousTarget = e.target; e.setTarget(mTarget); bool b = invokeEvent(e); if (previousTarget != null) { e.setTarget(previousTarget); } return(b); }
public static void ToPool(SAEventX e) { if (sEventPool.Count < 100) { e.data = e.target = null; sEventPool.Push(e); } }
protected void completeHandle(SAEventX e) { MonoDispatcher soundClip = (MonoDispatcher)e.target; string name = soundClip.name; _soundsOnce.Remove(name); soundClip.SetActive(false); }
public bool dispatchEvent(SAEventX e) { if (eventDispatcher == null) { return(false); } return(eventDispatcher.dispatchEvent(e)); }
public bool dispatchEvent(SAEventX e) { if (eventDispatcher == null) { eventDispatcher = new EventDispatcher(this); } return(eventDispatcher.dispatchEvent(e)); }
protected virtual void clickHandle(SAEventX e) { IListItemRender item = e.target as IListItemRender; selectedItem = item; if (hasEventListener(SAEventX.ITEM_CLICK)) { simpleDispatch(SAEventX.ITEM_CLICK, item); } }
public static bool dispatchEvent(this GameObject self, SAEventX e) { MonoDispatcher dispatcher = self.GetOrAddComponent <MonoDispatcher>(); if (dispatcher == null) { return(false); } return(dispatcher.dispatchEvent(e)); }
public bool simpleDispatch(string type, object data = null) { if (hasEventListener(type) == false) { return(false); } SAEventX e = SAEventX.FromPool(type, data); bool b = dispatchEvent(e); SAEventX.ToPool(e); return(b); }
private void resourceDisposeHandle(SAEventX e) { AssetResource res = e.target as AssetResource; res.removeEventListener(SAEventX.DISPOSE, resourceDisposeHandle); string uri = res.url.ToLower(); if (_resourceMap.ContainsKey(uri)) { _resourceMap.Remove(uri); } }
private void clickHandle() { if (_enabled == false) { return; } if (hasEventListener(SAEventX.CLICK)) { SAEventX e = SAEventX.FromPool(SAEventX.CLICK); bool b = dispatchEvent(e); SAEventX.ToPool(e); } }
public bool invokeEvent(SAEventX e) { if (mEventListeners == null) { return(false); } Signal signal; if (mEventListeners.TryGetValue(e.type, out signal) == false) { return(false); } SignalNode <SAEventX> t = signal.firstNode; if (t == null) { return(false); } List <Action <SAEventX> > temp = SimpleListPool <Action <SAEventX> > .Get(); int i = 0; while (t != null) { temp.Add(t.action); t = t.next; i++; } e.setCurrentTarget(e.target); Action <SAEventX> listener; for (int j = 0; j < i; j++) { listener = temp[j]; listener(e); // return true; } SimpleListPool <Action <SAEventX> > .Release(temp); return(true); }
public static SAEventX FromPool(string type, object data = null) { SAEventX e; if (sEventPool.Count > 0) { e = sEventPool.Pop(); e.reset(type, data); return(e); } else { e = new SAEventX(type, data); sEventPool.Push(e); return(e); } }
//----------------------------------------Protected---------------------------------------// //只能内部调用,防止被意外销毁 protected void hide(SAEventX e = null) { if (!isShow) { return; } doHide(); if (skin != null) { // UIBase uiBase = skin.GetComponent<UIBase>(); // if (uiBase != null) // { // LfUI.DespawnUI(uiBase.Id); // } GameObject.Destroy(skin); } }
private void btnHandler(SAEventX obj) { Camera.main.cullingMask &= ~(1 << 8); // string imgUrl = "UI/newShare/btn_close"; // Texture2D texture2D = Resources.Load<Texture2D>(imgUrl); // texture2D.EncodeToPNG(); // byte[] bytes = texture2D.GetRawTextureData(); //#if UNITY_IOS // mediaTagName = "MSG_INVITE"; // byte[] imgData = bytes; // int imgDataLen = imgData.Length; // WGPlatform.Instance.WGSendToWeixinWithPhoto(eWechatScene.WechatScene_Timeline, mediaTagName, imgData, // imgDataLen, messageExt, messageAction); //#elif UNITY_ANDROID // string imgLocalUrl = imgUrl; // WGPlatform.Instance.WGSendToWeixinWithPhotoPath(eWechatScene.WechatScene_Session, "777", imgLocalUrl, // "444", "555"); //#endif }
private void ItemClickHandler(SAEventX obj) { Debug.Log("pagelist点到了->" + pageList.selectedIndex); }
private void onAdd(SAEventX obj) { var newValue = value + _pad; checkValue(newValue); }
private void onMinus(SAEventX obj) { var newValue = value - _pad; checkValue(newValue); }
private void ClickHandler(SAEventX obj) { display.text = "点到了"; this.simpleDispatch(SAEventX.CLICK); }
protected void backgroundClickHandle(SAEventX e) { this.hide(e); }