public void RemoveIconComponent(string name) { IconInfo info = null; if (mIconComponents.TryGetValue(name, out info)) { CommonTool.DestroyObjectImmediate(info.IconComponent); info.StyleInfo = null; mIconComponents.Remove(name); } }
public override void UnInitBehaviors() { mOwner.UnsubscribeActorEvent(Actor.ActorEvent.AFTER_CREATE, OnAfterCreate); mOwner.UnsubscribeActorEvent(Actor.ActorEvent.MODEL_CHANGE, OnModelChange); mOwner.UnsubscribeActorEvent(Actor.ActorEvent.RES_LOADED_CHANGE, OnModelChange); base.UnInitBehaviors(); foreach (var icon in mIconComponents.Values) { if (icon != null) { CommonTool.DestroyObjectImmediate(icon.IconComponent); icon.StyleInfo = null; } } mIconComponents.Clear(); }
/// <summary> /// 初始化子弹和对应特效的位置和方向 /// </summary> /// <param name="effectObject">特效跟节点物体</param> /// <param name="effectObject">特效物体</param> /// <param name="kPos">特效位置</param> /// <param name="kRotation">特效初始方向</param> /// <param name="sDir">子弹飞行的方向</param> void InitEffectObject(GameObject bullet_object, GameObject effect_object) { if (bullet_object == null) { if (effect_object != null) { CommonTool.DestroyObjectImmediate(effect_object); } return; } if (effect_object == null) { return; } Transform bullet_trans = bullet_object.transform; // 设置特效位置和方向 effect_object.SetActive(false); Transform effect_trans = effect_object.transform; effect_trans.parent = bullet_trans; effect_trans.localPosition = Vector3.zero; effect_trans.localRotation = Quaternion.identity; effect_trans.localScale = Vector3.one; DelayEnableComponent delayEnable = bullet_object.GetComponent <DelayEnableComponent>(); if (delayEnable == null) { delayEnable = bullet_object.AddComponent <DelayEnableComponent>(); } delayEnable.DelayTime = m_DelayTime; delayEnable.SetEnable = true; delayEnable.SetEnableTarget(effect_object); }