/// <summary>
        /// Called the very first time the singleton instance is accessed, and thus, lazily
        /// instanced. This is automatically called in Awake() too.
        /// </summary>
        /// <param name="force"></param>
        /// <returns></returns>
        public override bool Init(bool force)
        {
#if DEBUG_RENDER
            bool proceed = base.Init(force);

            if (!proceed)
            {
                return(false);
            }

            debugMat = Utils.GetNewDebugMaterial();

            return(true);
#else
            return(false);
#endif
        }
Exemple #2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="emptyGo"></param>
        /// <param name="meshName"></param>
        /// <param name="numVertices"></param>
        /// <param name="numTriangles"></param>
        public ProceduralMesh(GameObject emptyGo, string meshName, int numVertices, int numTriangles)
        {
            Go       = emptyGo;
            Filter   = emptyGo.AddComponent <MeshFilter>();
            Renderer = emptyGo.AddComponent <MeshRenderer>();

            // set a simple debug material so that we can manually color the mesh
            Renderer.material = Utils.GetNewDebugMaterial();

            Mesh.name = meshName;
            Mesh.MarkDynamic();

            Vertices  = new Vector3[numVertices];
            Triangles = new int[numTriangles];
            Colors    = new Color[numVertices];

            // use the appropiate format to support meshes with more than 65534 vertices
            if (numVertices >= Mathf.Pow(2, 16) - 2)
            {
                Mesh.indexFormat = IndexFormat.UInt32;
            }
        }