Esempio n. 1
0
        public void OverrideAnimationClip(string path)
        {
            if (_animationPath == path)
            {
                return;
            }
            _animationPath = path;
            if (_animationClipProxy != null)
            {
                _animationClipProxy.UnloadProxy();
            }
            _animationClipProxy = ResourceMgr.singleton.LoadAssetAsync(path);
            _animationClipProxy.AddLoadFinishCallBack(() =>
            {
                var clip = _animationClipProxy.GetUnityAsset <AnimationClip>();
                if (Machine.AnimatorOverrideController && clip)
                {
                    Machine.AnimatorOverrideController[StateName] = clip;
                    Machine.Animator.runtimeAnimatorController    = Machine.AnimatorOverrideController;
                    //_animator.Rebind();

                    _animationClip = clip;
                }
            });
        }
        protected override void InitializeEx()
        {
            base.InitializeEx();
            _partDataDict = new Dictionary <ModelPart, string>
            {
                [ModelPart.ModelHead]   = ModelConfig.HeadArray[0],
                [ModelPart.ModelBody]   = ModelConfig.BodyArray[0],
                [ModelPart.ModelHand]   = ModelConfig.HandArray[0],
                [ModelPart.ModelFeet]   = ModelConfig.FeetArray[0],
                [ModelPart.ModelWeapon] = ModelConfig.WeaponArray[0]
            };

            _skeletonProxy = ResourceMgr.singleton.LoadAssetAsync(_skeletonPath);
            _skeletonProxy.AddLoadFinishCallBack(() =>
            {
                _skeleton = _skeletonProxy.GetInstantiateObject <GameObject>();
                OnLoaded();
            });
            _partProxyDict     = new Dictionary <ModelPart, AssetBundleAssetProxy>();
            _tempPartProxyDict = new Dictionary <ModelPart, AssetBundleAssetProxy>();

            foreach (var temp in _partDataDict)
            {
                var part  = temp.Key;
                var name  = temp.Value;
                var proxy = ResourceMgr.singleton.LoadAssetAsync(name);
                _partProxyDict[part] = proxy;
                proxy.AddLoadFinishCallBack(OnLoaded);
            }
        }
 protected override void InitializeEx()
 {
     base.InitializeEx();
     _skeletonProxy = ResourceMgr.singleton.LoadAssetAsync(_skeletonPath);
     _skeletonProxy.AddLoadFinishCallBack(() =>
     {
         _skeleton = _skeletonProxy.GetInstantiateObject <GameObject>();
         OnLoadFinish();
     });
 }
Esempio n. 4
0
 public void Initialize(Animator animator, string path)
 {
     _animator             = animator;
     _runtimeAnimatorProxy = ResourceMgr.singleton.LoadAssetAsync(path);
     _runtimeAnimatorProxy.AddLoadFinishCallBack(() =>
     {
         var ctrl = _runtimeAnimatorProxy.GetUnityAsset <RuntimeAnimatorController>();
         if (ctrl)
         {
             _animator.runtimeAnimatorController = ctrl;
             _animatorOverrideController         = new AnimatorOverrideController(ctrl);
             _animator.Rebind();
         }
     });
 }
Esempio n. 5
0
 public void Init(AbsEntity entity, string path, bool isAsync = true)
 {
     Entity       = entity;
     ResPath      = path;
     IsLoadFinish = false;
     proxy        = ResourceMgr.singleton.LoadAssetAsync(ResPath);
     proxy.AddLoadFinishCallBack(() =>
     {
         gameObject      = proxy.GetInstantiateObject <GameObject>();
         gameObject.name = entity.UID.ToString();
         IsLoadFinish    = true;
         Trans           = gameObject.transform;
         _loadFinishHandler?.Invoke(this);
     });
 }
 public void Init(Animator animator, string path)
 {
     _animator             = animator;
     _runtimeAnimatorProxy = ResourceMgr.Instance.LoadAssetAsync(path);
     _runtimeAnimatorProxy.AddLoadFinishCallBack(() =>
     {
         RuntimeAnimatorController ctrl = _runtimeAnimatorProxy.GetUnityAsset <RuntimeAnimatorController>();
         if (ctrl)
         {
             _animator.runtimeAnimatorController = ctrl;
             _animatorOverrideController         = ctrl as AnimatorOverrideController;
             _animator.Rebind();
         }
     });
 }
Esempio n. 7
0
        public void Initialize()
        {
            if (null == Entity)
            {
                return;
            }
            Animator = Entity.Animator;
            _runtimeAnimatorProxy = ResourceMgr.singleton.LoadAssetAsync(AssetPath);
            _runtimeAnimatorProxy.AddLoadFinishCallBack(() =>
            {
                var ctrl = _runtimeAnimatorProxy.GetUnityAsset <RuntimeAnimatorController>();
                if (ctrl)
                {
                    AnimatorOverrideController         = new AnimatorOverrideController(ctrl);
                    Animator.runtimeAnimatorController = AnimatorOverrideController;
                    Animator.Rebind();
                    Enable = true;
                    TransToDefault();

                    //TODO
                    foreach (var state in StateList)
                    {
                        var str = string.Empty;
                        if (state.StateName == StateNameEnum.Idle.ToString())
                        {
                            str = "Animation/Skeleton/Idle.anim";
                        }
                        if (state.StateName == StateNameEnum.Move.ToString())
                        {
                            str = "Animation/Skeleton/Run.anim";
                        }
                        if (state.StateName == StateNameEnum.Skill.ToString())
                        {
                            str = "Animation/Skeleton/Attack.anim";
                        }
                        if (state.StateName == StateNameEnum.Special.ToString())
                        {
                            str = "Animation/Skeleton/Damage.anim";
                        }
                        if (state.StateName == StateNameEnum.Dead.ToString())
                        {
                            str = "Animation/Skeleton/Death.anim";
                        }
                        state.Initialize(str);
                    }
                }
            });
        }
 public void OverrideAnimationClip(string name, string path, bool autoPlay = true)
 {
     _animationClipProxy = ResourceMgr.Instance.LoadAssetAsync(path);
     _animationClipProxy.AddLoadFinishCallBack(() =>
     {
         AnimationClip clip = _animationClipProxy.GetUnityAsset <AnimationClip>();
         if (_animatorOverrideController && clip)
         {
             _animatorOverrideController[name]   = clip;
             _animator.runtimeAnimatorController = _animatorOverrideController;
             _AnimationInfo.Data[name]           = clip;
             _animator.Rebind();
             if (autoPlay)
             {
                 _animator.Play(name);
             }
         }
     });
 }
Esempio n. 9
0
 public void Initialize()
 {
     if (null == Entity)
     {
         return;
     }
     Animator = Entity.Animator;
     _runtimeAnimatorProxy = ResourceMgr.singleton.LoadAssetAsync(AssetPath);
     _runtimeAnimatorProxy.AddLoadFinishCallBack(() =>
     {
         RuntimeAnimatorController ctrl = _runtimeAnimatorProxy.GetUnityAsset <RuntimeAnimatorController>();
         if (ctrl)
         {
             Animator.runtimeAnimatorController = ctrl;
             AnimatorOverrideController         = new AnimatorOverrideController(ctrl);
             Animator.Rebind();
             Enable = true;
             TransToDefault();
         }
     });
 }
Esempio n. 10
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     uiRootProxy = ResourceMgr.singleton.LoadAssetAsync(_uiRoot);
     uiRootProxy.AddLoadFinishCallBack(() =>
     {
         var go = uiRootProxy.GetInstantiateObject <GameObject>();
         go.transform.localPosition = Vector3.zero;
         MainUICamera = go.transform.Find("MainUICamera").GetComponent <Camera>();
         DontDestroyOnLoad(go);
         OnInitFinish();
     });
     mainCameraProxy = ResourceMgr.singleton.LoadAssetAsync(_mainCamera);
     mainCameraProxy.AddLoadFinishCallBack(() =>
     {
         var go = mainCameraProxy.GetInstantiateObject <GameObject>();
         go.transform.localPosition = Vector3.zero;
         MainCamera = go.transform.GetComponent <Camera>();
         DontDestroyOnLoad(go);
         OnInitFinish();
     });
 }
Esempio n. 11
0
 private void LoadAtlas()
 {
     _proxy = ResourceMgr.singleton.LoadAssetAsync(AtlasPath);
     _proxy.AddLoadFinishCallBack(OnLoadFinish);
 }