Esempio n. 1
0
        private void LoadTarget(ActorConfigEditor actor)
        {
            string modelName = CfgManager.Model[actor.ModelName].ModelPath;

            if (Target != null && Target.name.Equals(modelName))
            {
                return;
            }

            if (Target != null)
            {
                UnityEngine.Object.DestroyImmediate(Target);
            }
            Target = ActorHelper.Instantiate(actor);
            Target.transform.parent   = CharacterDir.transform;
            Target.transform.position = Vec3.forward * -10;
            Target.transform.forward  = Vec3.forward;
            var cap = Target.GetComponent <CapsuleCollider>();

            if (cap != null)
            {
                var collider = LoadCollider(_charColliderName, Target);
                collider.SetActive(_showCollider);
                float size = cap.radius;
                collider.transform.localScale = Vec3.one * size;
            }
            else
            {
                Debug.LogErrorFormat("{0} 角色没有渲染组件!", Target.name);
            }
        }
Esempio n. 2
0
        //-- 加载角色行为时加载资源
        private void LoadSelf(ActorConfigEditor actor)
        {
            string modelName = CfgManager.Model[actor.ModelName].ModelPath;

            if (Self != null && Self.name.Equals(modelName))
            {
                return;
            }

            if (Self != null)
            {
                UnityEngine.Object.DestroyImmediate(Self);
            }
            Self = ActorHelper.Instantiate(actor);
            Self.transform.parent   = CharacterDir.transform;
            Self.transform.position = Vec3.forward * 10;
            Self.transform.forward  = -Vec3.forward;
            //if (_showCollider)
            //{
            //    var ctrl = Self.GetComponent<CharacterController>();
            //    if (ctrl != null)
            //    {
            //        var collider = LoadCollider(_charColliderName);
            //        collider.transform.localScale = Vec3.one * ctrl.radius;
            //    }
            //}
        }
Esempio n. 3
0
        public GameObject LoadCollider(string collider, GameObject parent = null)
        {
            string     path = string.Format("{0}/{1}.fbx", _config.ColliderRelativeDir, collider);
            GameObject col  = ActorHelper.Instantiate(path, parent);

            col.GetComponent <Renderer>().material = new Material(Shader.Find("Transparent/Diffuse"));
            return(col);
        }