public override void ApplyMeshData(bool removeFromMemory) { if (topologyCache != GetTopology() || numIndicesCache != indexCount || numVerticesCache != vertexCount) { unityMesh.Clear(); topologyCache = GetTopology(); numIndicesCache = indexCount; numVerticesCache = vertexCount; } if (IsDynamic()) { unityMesh.MarkDynamic(); } ApplyVertices(); ApplyNormals(); ApplyTextureCoordinates(); ApplyTangents(); ApplyColors(); ApplyIndices(); RecalculateBounds(); if (removeFromMemory) { Clear(); } unityMesh.UploadMeshData(removeFromMemory); }
protected override void OnCreateManager() { base.OnCreateManager(); instanceMesh = new UnityEngine.Mesh(); instanceMesh.SetVertices( new System.Collections.Generic.List <UnityEngine.Vector3>() { new UnityEngine.Vector3(-0.25f, 0f, 0f), new UnityEngine.Vector3(-0.25f, 0.5f, 0f), new UnityEngine.Vector3(0.25f, 0f, 0f), new UnityEngine.Vector3(0.25f, 0.5f, 0f), } ); instanceMesh.SetUVs( 0, new System.Collections.Generic.List <UnityEngine.Vector2>() { new UnityEngine.Vector3(0f, 0f), new UnityEngine.Vector3(0f, 1f), new UnityEngine.Vector3(1f, 0f), new UnityEngine.Vector3(1f, 1f), } ); instanceMesh.SetTriangles( new System.Collections.Generic.List <int>() { 0, 1, 2, 3, 2, 1 }, 0 ); instanceMesh.UploadMeshData(true); instanceCount = 0; InsObjSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(InsObj)); argsBuffer = new UnityEngine.ComputeBuffer(1, args.Length * sizeof(uint), UnityEngine.ComputeBufferType.IndirectArguments); InsObjs = null; InsObjsID = UnityEngine.Shader.PropertyToID("InsObjs"); }
protected override void OnCreateManager() { base.OnCreateManager(); materialPropertyBlock = new UnityEngine.MaterialPropertyBlock(); instanceMesh = new UnityEngine.Mesh(); instanceMesh.SetVertices( new System.Collections.Generic.List <UnityEngine.Vector3>() { new UnityEngine.Vector3(-0.25f, 0f, 0f), new UnityEngine.Vector3(-0.25f, 0.5f, 0f), new UnityEngine.Vector3(0.25f, 0f, 0f), new UnityEngine.Vector3(0.25f, 0.5f, 0f), } ); instanceMesh.SetUVs( 0, new System.Collections.Generic.List <UnityEngine.Vector2>() { new UnityEngine.Vector3(0f, 0f), new UnityEngine.Vector3(0f, 1f), new UnityEngine.Vector3(1f, 0f), new UnityEngine.Vector3(1f, 1f), } ); instanceMesh.SetTriangles( new System.Collections.Generic.List <int>() { 0, 1, 2, 3, 2, 1 }, 0 ); instanceMesh.UploadMeshData(true); TRSs = new UnityEngine.Matrix4x4[INSTANCE_MAX]; columnIndx = new float[INSTANCE_MAX]; rowIndx = new float[INSTANCE_MAX]; ColumnID = UnityEngine.Shader.PropertyToID("_ColumnIndx"); RowID = UnityEngine.Shader.PropertyToID("_RowIndx"); }