Beispiel #1
0
        protected void Init()
        {
            GameObject prefab = WarRes.GetPrefab(WarRes.Unit_Shadow);
            GameObject go     = (GameObject)GameObject.Instantiate(prefab as UnityEngine.Object);

            go.name = "War_Shadow-" + unitData.id;
            go.transform.SetParent(War.scene.rootShadow);
            shadow        = go.GetComponent <UnitShadow>();
            shadow.target = transform;
            shadow.SetPosition();

            OnChangeAvatar(unitAgent);
        }
Beispiel #2
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            if (shadow != null)
            {
                GameObject.Destroy(shadow.gameObject);
            }

            if (unitAgent != null)
            {
                unitAgent.sChangeAvatar -= OnChangeAvatar;
            }
            unitAgent = null;
            shadow    = null;
        }