public void CreateMeshGameObject(CreateRoadMeshScripts.MeshSet meshset, string objName, string materialName) { var materials = new Dictionary <string, string>() { { "TileMaterial", "Models/Background/Materials/RoadMaterial" }, { "CurveTileMaterial", "Models/Background/Materials/CrossRoadMaterial" }, { "CrossTileMaterial", "Models/Background/Materials/CrossRoadMaterial" }, }; var obj = new GameObject(objName); obj.transform.parent = this.parentTransform; var meshFilter = obj.AddComponent <MeshFilter>(); var mesh = meshset.CreateMesh(); meshFilter.sharedMesh = mesh; var meshRenderer = obj.AddComponent <MeshRenderer>(); meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; meshRenderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; meshRenderer.receiveShadows = false; meshRenderer.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; var id = materials[materialName] + Liver.RaceWindow.RoadMaterial.ToString(); meshRenderer.sharedMaterial = Resources.Load <Material>(id); }
/// <summary> /// メッシュを持つゲームオブジェクトを生成する。 /// </summary> /// <param name="meshset">Meshset.</param> /// <param name="objName">Object name.</param> /// <param name="materialName">Material name.</param> private static void CreateMeshGameObject(CreateRoadMeshScripts.MeshSet meshset, string objName, string materialName) { Mesh mesh = meshset.CreateMesh(); var obj = new GameObject(objName); var meshFilter = obj.AddComponent <MeshFilter>(); var meshRenderer = obj.AddComponent <MeshRenderer>(); meshFilter.sharedMesh = mesh; meshRenderer.sharedMaterial = Resources.Load <Material>(materialName); }
private static GameObject CreateRoadGameObject(string objectName, CreateRoadMeshScripts.MeshSet meshSet) { var obj = new GameObject(objectName); var meshFilter = obj.AddComponent <MeshFilter>(); var mesh = meshSet.CreateMesh(); meshFilter.sharedMesh = mesh; var meshRenderer = obj.AddComponent <MeshRenderer>(); meshRenderer.sharedMaterial = Resources.Load <Material>("Demo/StandardGray"); var meshCollider = obj.AddComponent <MeshCollider>(); meshCollider.sharedMesh = mesh; return(obj); }