public override void CreateActualModel() { m_bIsCreatingModel = true; DataAvatarModel data = GameData <DataAvatarModel> .dataMap[(int)Vocation]; if (data != null) { ResourceManager.singleton.LoadModel(data.PrefabPath, new AssetRequestFinishedEventHandler((assetRequest) => { GameObject gameobject = assetRequest.AssetResource.MainAsset as GameObject; gameobject = GameObject.Instantiate(gameobject) as GameObject; gameobject.tag = "Player"; ActorMyself actor = gameobject.GetComponent <ActorMyself>(); if (actor == null) { actor = gameobject.AddComponent <ActorMyself>(); } motor = gameobject.GetComponent <GameMotorMyself>(); if (motor == null) { motor = gameobject.AddComponent <GameMotorMyself>(); } animator = gameobject.GetComponent <Animator>(); audioSource = gameobject.GetComponent <AudioSource>(); if (null == audioSource) { audioSource = gameobject.AddComponent <AudioSource>(); } audioSource.rolloffMode = AudioRolloffMode.Custom; sfxHandler = gameobject.AddComponent <SfxHandler>(); actor.m_motor = motor; actor.Entity = this; GameObject = gameobject; Transform = gameobject.transform; Transform.gameObject.layer = 8; UpdatePosition(); if (data.Scale > 0) { Transform.localScale = new Vector3(data.Scale, data.Scale, data.Scale); } GameInputManager.singleton.Init(gameobject.GetComponent <PCGameInputManager>(), this); gameobject.SetActive(false); gameobject.SetActive(true); m_bIsCreatingModel = false; }), Client.Common.AssetPRI.DownloadPRI_Plain); } else { Debug.Log("找不到DataAvartarModel文件"); } }
public override void CreateActualModel() { base.CreateActualModel(); DataAvatarModel data = GameData <DataAvatarModel> .dataMap[(int)Vocation]; if (data != null) { ResourceManager.singleton.LoadModel(data.PrefabPath, new AssetRequestFinishedEventHandler((assetRequest) => { GameObject gameobject = assetRequest.AssetResource.MainAsset as GameObject; gameobject = GameObject.Instantiate(gameobject) as GameObject; gameobject.name = "RenderNode"; gameobject.transform.SetParent(Transform); gameobject.transform.localPosition = Vector3.zero; gameobject.transform.localScale = Vector3.one; gameobject.transform.localRotation = Quaternion.identity; GameObject = gameobject; if (!IsVisiable) { this.SetVisiableWhenLoad(IsVisiable); } GatherRenderNodeInfo(gameobject); GatherMeshes(gameobject); Animation anim = gameobject.GetComponent <Animation>(); anim.playAutomatically = false; anim.cullingType = AnimationCullingType.AlwaysAnimate; if (null == anim) { Debug.LogError("没有Animation组件"); } else { animation = anim; } for (int k = 0; k < gameobject.transform.childCount; k++) { Transform childNode = gameobject.transform.GetChild(k); if (childNode.name == "Bip01") { boneRoot = childNode.gameObject; break; } } //关闭unity自带的投影 for (int k = 0; k < gameobject.transform.childCount; ++k) { Transform kChildTransform = gameobject.transform.GetChild(k); GameObject kChildObject = kChildTransform.gameObject; SkinnedMeshRenderer kSkinnedMeshRenderer = kChildObject.GetComponent <SkinnedMeshRenderer>(); if (kSkinnedMeshRenderer != null) { kSkinnedMeshRenderer.receiveShadows = false; } MeshRenderer kStaticMeshRenderer = kChildObject.GetComponent <MeshRenderer>(); if (kStaticMeshRenderer != null) { kStaticMeshRenderer.receiveShadows = false; } } //加载投影 this.PlayShow(); uint[] equipment = new uint[] { 1100, 1101, 1102, 1103, 1104, 1105, 1106 }; UpdateAvatar(equipment); }), Client.Common.AssetPRI.DownloadPRI_Plain); } }