Example #1
0
        /// <summary>
        /// 加载animation资源
        /// </summary>
        /// <param name="prefabPath"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        public AnimationEventFromScript Load(string prefabPath, ProcessWhenAnimationFinished handler)
        {
            //设置名称
            // name = prefabPath;
            //设置回调
            finishedHandler = handler;

            Object orgObj = CoreEntry.gResLoader.Load(prefabPath);

            if (orgObj != null)
            {
                gameObj         = GameObject.Instantiate(orgObj) as GameObject;
                eventFromScript = gameObj.AddComponent <AnimationEventFromScript>();
                finishedEvent   = eventFromScript.AddAnimationFinishedEvent <ImbededAnimationFinishedProcessor>("ProcessWhenAnimationFinished");

                ImbededAnimationFinishedProcessor tmp = eventFromScript.GetComponent <ImbededAnimationFinishedProcessor>();
                if (tmp != null)
                {
                    tmp.RefObj = this;
                }


                orgObj = null;
                //Resources.UnloadUnusedAssets();
            }
            else
            {
                LogMgr.ErrorLog("ImbededAnimation: Can not find animation prefab: {0}.", prefabPath);
            }
            return(eventFromScript);
        }
Example #2
0
 public ImbededAnimation(string prefabPath, ProcessWhenAnimationFinished handler)
 {
     Load(prefabPath, handler);
 }