示例#1
0
        public MeshComponent AddComponent(MeshComponentType componentType)
        {
            var comp = MeshComponent.Create(componentType);

            Components.Add(comp);
            return(comp);
        }
 public void SetTarget(SkinnedMeshRenderer newTarget)
 {
     if (newTarget == null)
     {
         return;
     }
     meshComponentType   = MeshComponentType.SkinnedMeshRenderer;
     skinnedMeshRenderer = newTarget;
     UpdateMesh();
     Target();
 }
 public void SetTarget(MeshFilter newTarget)
 {
     if (newTarget == null)
     {
         return;
     }
     meshComponentType = MeshComponentType.MeshFilter;
     meshFilter        = newTarget;
     UpdateMesh();
     Target();
 }
示例#4
0
 public T GetComponent <T>(MeshComponentType componentType)
     where T : MeshComponent
 {
     foreach (var comp in Components)
     {
         if (comp.Type == componentType && comp is T)
         {
             return((T)comp);
         }
     }
     return(default);
示例#5
0
        public static MeshComponent Create(MeshComponentType componentType)
        {
            switch (componentType)
            {
            case MeshComponentType.Position:
                return(new MeshComponent <Vector3>(componentType));

            case MeshComponentType.Normal:
                return(new MeshComponent <Vector3>(componentType));

            case MeshComponentType.Color:
                return(new MeshComponent <Vector4>(componentType));

            case MeshComponentType.UV:
                return(new MeshComponent <Vector2>(componentType));

            default:
                throw new ArgumentOutOfRangeException(nameof(componentType));
            }
        }