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(); }
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);
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)); } }