- Home /
How to render a mesh twice without re-instancing a gameobject
Hi,
i have a gameobject with a mesh, and i would like to render several versions of it. I would like to do it without re-instancing it.
I did this:
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(MeshFilter), typeof(MeshRenderer))]
public class meshClone : MonoBehaviour {
public GameObject father;
public Material material;
MeshFilter meshFilter;
//MeshRenderer meshRenderer;
void Start () {
meshFilter = GetComponent<MeshFilter> ();
//meshRenderer = GetComponent <MeshRenderer> ();
if (father != null) {
meshFilter = (MeshFilter)father.GetComponent<MeshFilter> ();
} else {
print ("Huérfano de padre y madre");
}
}
void Update () {
Graphics.DrawMeshNow (meshFilter.mesh, Vector3.zero, Quaternion.identity);
print ("Vertices " + meshFilter.mesh.vertexCount );
print ("Triangles " + meshFilter.mesh.triangles.Length );
}
}
It doesn't work. Is it inevitable to re-instance the gameObject? Any clue on what i'm doing wrong? I would expect that in the inspector, the Mesh field of my object (the new object) will get assigned once i run the game. However, is keeps saying "None". Maybe that points somewhere?
thanks,
Sergio
Comment
Your answer
Follow this Question
Related Questions
How to create a plow of fields ? 0 Answers
Using MeshFilter.mesh with static ground plane makes object turn into a plane. 0 Answers
Odd shadow behaviour from generated mesh 1 Answer
Creating a 3D curve? 0 Answers
Dymanic Mesh Hiding 2 Answers