private void OnEffectEntityLoaded() { if (Widget == null) { EntityManager.Instance.FreeEntity(this.m_effectEntity); this.m_effectEntity = null; //GameEvents.SceneEvents.FreeEntityFromScene.SafeInvoke(this.m_effectEntity); } else { this.m_effectEntity.EntityObject.EntityTransform.SetParent(Widget, false); this.m_effectEntity.EntityObject.EntityTransform.localPosition = Vector3.zero; this.m_effectEntity.EntityScale = Vector3.one; this.m_effectEntity.EntityObject.Layer = LayerDefine.UIShowLayer; if (ClearRotation) { this.m_effectEntity.EntityObject.EntityTransform.localEulerAngles = Vector3.zero; } m_effectScaleComponent = this.m_effectEntity.EntityObject.EntityGameObject.GetOrAddComponent <UIEffectScale>(); m_effectScaleComponent.Scale = m_effectScale; m_effectScaleComponent.RealScale = m_realScale; m_effectScaleComponent.SetSortingOrder(m_renderQueue); m_effectScaleComponent.SetSortingLayerName(m_sortingLayerName); FitUIScale = true; OnPlayEffect?.Invoke(); LogicHandler.UIFrame.SetFrameDirty(); this.m_effectEntity.Visible = Visible; } }
private void LoadEffectEntityInternal() { this.m_effectEntity = EntityManager.Instance.AllocEntity <EffectEntity>(EntityType.Effect, EffectPrefabName); this.m_effectEntity.OnEntityLoaded = OnEffectEntityLoaded; this.m_effectEntity.LifeCycle = EntityLifecycle.MANUAL; this.m_effectEntity.Load(); }
/// <summary> /// 向场景添加特效实体(LazyLoad) /// </summary> /// <param name="effectName"></param> /// <returns></returns> public EffectEntity AddLazyEffect(string effectName) { EffectEntity effectEntity = EntityManager.Instance.AllocEntity <EffectEntity>(EntityType.Effect, effectName); AddSceneEntity(effectEntity); return(effectEntity); }
private void DisposeEffectEntity() { if (m_effectEntity != null) { //GameEvents.SceneEvents.FreeEntityFromScene.SafeInvoke(this.m_effectEntity); //EntityManager.Instance.FreeEntity(this.m_effectEntity); //手动销毁 this.m_effectEntity.InterruptLoadEntity(); EntityManager.Instance.DestroyEntity(this.m_effectEntity.EntityId); } this.m_effectEntity = null; }
/// <summary> /// 向场景添加特效 /// </summary> /// <param name="effectName"></param> /// <param name="position"></param> /// <param name="rotation"></param> /// <param name="scale"></param> /// <param name="effectLifeTime"></param> /// <returns></returns> public EntityBase AddEffect(string effectName, Vector3 position, Vector3 rotation, Vector3 scale, float effectLifeTime) { EffectEntity effectEntity = EntityManager.Instance.AllocEntity <EffectEntity>(EntityType.Effect, effectName);; effectEntity.EntityPosition = position; effectEntity.EntityEulerRotation = rotation; effectEntity.EntityScale = scale; effectEntity.Load(); AddSceneEntity(effectEntity); return(effectEntity); }
/// <summary> /// 播放UI特效 /// </summary> private void PlayEffect() { if (this.m_effectEntity != null) { if (this.m_effectEntity.AssetLoadStatus == ResStatus.WAIT && this.m_effectEntity.AssetName != EffectPrefabName) { this.m_effectEntity.InterruptLoadEntity(); this.m_effectEntity = null; LoadEffectEntityInternal(); } } else { LoadEffectEntityInternal(); } }