using UnityEditor;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour{
void Start(){
var m = new Mesh();
var v = new Vector3(0, 0, 0);
var d = 0.5f;
m.vertices = new Vector3[]{v,v+d*Vector3.up, v+d* Vector3.right};
m.triangles = new int[] { 0, 1, 2};
m.uv=new Vector2[]{d*new Vector2(1,1),d*new Vector2(1,0),d*new Vector2(0,1)};
m.RecalculateBounds();
m.RecalculateNormals();
var mr = gameObject.GetComponent<MeshRenderer>();
if (mr == null) gameObject.AddComponent<MeshRenderer>();
var mf = gameObject.GetComponent<MeshFilter>();
if (mf == null) mf = gameObject.AddComponent<MeshFilter>();
mf.sharedMesh = m;
AssetDatabase.CreateAsset(m,"Assets/Resources/2207170827/test.asset");
}
}
Рубрики