static public int constructor(IntPtr l) { UnityEngine.MeshFilter o; o = new UnityEngine.MeshFilter(); pushObject(l, o); return(1); }
public virtual void Reset() { if (meshFilter != null) meshFilter.sharedMesh = null; if (mesh != null) DestroyImmediate(mesh); if (renderer != null) renderer.sharedMaterial = null; mesh = null; mesh1 = null; mesh2 = null; lastVertexCount = 0; vertices = null; colors = null; uvs = null; sharedMaterials = new Material[0]; submeshMaterials.Clear(); submeshes.Clear(); valid = false; if(skeleton==null) { return; } valid = true; meshFilter = GetComponent<MeshFilter>(); mesh1 = newMesh(); mesh2 = newMesh(); vertices = new Vector3[0]; if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default") skeleton.SetSkin(initialSkinName); }
//------------------------------------------------------------------------------------------------------------ private void OnGUI() { m_MeshFilter = (MeshFilter)EditorGUILayout.ObjectField("MeshFilter", m_MeshFilter, typeof(MeshFilter), true); if (m_MeshFilter != null) { if (GUILayout.Button("Export OBJ")) { var lOutputPath = EditorUtility.SaveFilePanel("Save Mesh as OBJ", "", m_MeshFilter.name + ".obj", "obj"); if (File.Exists(lOutputPath)) { File.Delete(lOutputPath); } var lStream = new FileStream(lOutputPath, FileMode.Create); var lOBJData = m_MeshFilter.sharedMesh.EncodeOBJ(); OBJLoader.ExportOBJ(lOBJData, lStream); lStream.Close(); } } else { GUILayout.Label("Please provide a MeshFilter"); } }
void Start () { meshFilter = GetComponent<MeshFilter>(); switch (shape) { case PGMesh.Shape.Triangle: meshFilter.sharedMesh = PGMesh.Triangle(Vector3.left / 2 + Vector3.down / 2, Vector3.up, Vector3.right / 2 + Vector3.down / 2); break; case PGMesh.Shape.Quad: meshFilter.sharedMesh = PGMesh.Quad(Vector3.left / 2 + Vector3.down / 2, Vector3.right, Vector3.up); break; case PGMesh.Shape.Plane: meshFilter.sharedMesh = PGMesh.Plane(Vector3.left / 2 + Vector3.down / 2, Vector3.right, Vector3.up, 1, 3); break; case PGMesh.Shape.Tetrahedron: meshFilter.sharedMesh = PGMesh.Tetrahedron(1); break; case PGMesh.Shape.Cube: meshFilter.sharedMesh = PGMesh.Cube(1); break; case PGMesh.Shape.Octahedron: meshFilter.sharedMesh = PGMesh.Octahedron(1); break; case PGMesh.Shape.Icosahedron: meshFilter.sharedMesh = PGMesh.Icosahedron(1); break; } }
public void Initialize() { gameObject.AddComponent<MeshRenderer>(); mf = gameObject.AddComponent<MeshFilter>(); renderer.material = new Material(Shader.Find("VertexLit")); Draw(0); }
public static void MeshToFile(MeshFilter mf, string filename) { using (StreamWriter sw = new StreamWriter(filename)) { sw.Write(MeshToString(mf)); } }
public Node(GameObject source) { id = IdManager.Instance.CreateNodeId(); name = source.name; enabled = source.activeInHierarchy; position = source.transform.localPosition; rotation = source.transform.localRotation; scale = source.transform.localScale; components = new List <Component>(); UnityEngine.Light light = source.GetComponent <UnityEngine.Light>(); if (light) { components.Add(new Light(light)); } UnityEngine.Camera camera = source.GetComponent <UnityEngine.Camera>(); if (camera) { components.Add(new Camera(camera)); } UnityEngine.MeshRenderer meshRenderer = source.GetComponent <UnityEngine.MeshRenderer>(); UnityEngine.MeshFilter meshFilter = source.GetComponent <UnityEngine.MeshFilter>(); if (meshRenderer && meshFilter) { components.Add(new StaticModel(meshRenderer, meshFilter)); } nodes = new List <Node>(); foreach (UnityEngine.Transform child in source.transform) { nodes.Add(new Node(child.gameObject)); } }
public static void MeshToFile(MeshFilter mf, string filename) { using (StreamWriter streamWriter = new StreamWriter(filename)) { streamWriter.Write(RTPObjExporter.MeshToString(mf)); } }
public void NewTarget(GameObject targ) { if ( target != targ ) { target = targ; t = 0.0f; if ( target ) { filter = (MeshFilter)target.GetComponent(typeof(MeshFilter)); if ( filter != null ) center = filter.mesh.bounds.center; else { render = (MeshRenderer)target.GetComponent(typeof(MeshRenderer)); if ( render != null ) center = render.bounds.center; else { srender = (SkinnedMeshRenderer)target.GetComponent(typeof(SkinnedMeshRenderer)); if ( srender != null ) center = srender.bounds.center; } } } } }
private void RestoreOriginalMeshesUV(MeshFilter[] meshFilters, Vector2[][] backupUVs) { for (int i = 0; i < meshFilters.Length; i++) { meshFilters[i].mesh.uv = backupUVs[i]; } }
void Start() { mesh = new Mesh(); mesh.name = "GeneratedMesh"; meshFilter = GetComponent<MeshFilter>(); meshFilter.mesh = mesh; }
public void ManualUpdate() { if (Group != null) { if (MeshFilter == null) MeshFilter = gameObject.AddComponent<MeshFilter>(); if (MeshRenderer == null) MeshRenderer = gameObject.AddComponent<MeshRenderer>(); if (MeshFilter.sharedMesh != Mesh) { SgtHelper.BeginStealthSet(MeshFilter); { MeshFilter.sharedMesh = Mesh; } SgtHelper.EndStealthSet(); } if (MeshRenderer.sharedMaterial != Group.Material) { SgtHelper.BeginStealthSet(MeshRenderer); { MeshRenderer.sharedMaterial = Group.Material; } SgtHelper.EndStealthSet(); } } }
public void ManualUpdate(Mesh mesh, Material material, Quaternion rotation) { if (Ring != null) { if (MeshFilter == null) MeshFilter = gameObject.AddComponent<MeshFilter>(); if (MeshRenderer == null) MeshRenderer = gameObject.AddComponent<MeshRenderer>(); if (MeshFilter.sharedMesh != mesh) { SgtHelper.BeginStealthSet(MeshFilter); { MeshFilter.sharedMesh = mesh; } SgtHelper.EndStealthSet(); } if (MeshRenderer.sharedMaterial != material) { SgtHelper.BeginStealthSet(MeshRenderer); { MeshRenderer.sharedMaterial = material; } SgtHelper.EndStealthSet(); } SgtHelper.SetLocalRotation(transform, rotation); } }
public static string MeshToString(MeshFilter mf) { Mesh m = mf.sharedMesh; Material[] mats = mf.renderer.sharedMaterials; StringBuilder sb = new StringBuilder(); sb.Append("g ").Append(mf.name).Append("\n"); foreach(Vector3 v in m.vertices) { sb.Append(string.Format("v {0} {1} {2}\n",v.x,v.y,v.z)); } sb.Append("\n"); foreach(Vector3 v in m.normals) { sb.Append(string.Format("vn {0} {1} {2}\n",v.x,v.y,v.z)); } sb.Append("\n"); foreach(Vector3 v in m.uv) { sb.Append(string.Format("vt {0} {1}\n",v.x,v.y)); } for (int material=0; material < m.subMeshCount; material ++) { sb.Append("\n"); sb.Append("usemtl ").Append(mats[material].name).Append("\n"); sb.Append("usemap ").Append(mats[material].name).Append("\n"); int[] triangles = m.GetTriangles(material); for (int i=0;i<triangles.Length;i+=3) { sb.Append(string.Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", triangles[i]+1, triangles[i+1]+1, triangles[i+2]+1)); } } return sb.ToString(); }
private void Awake() { mf = GetComponent<MeshFilter>(); if (mf != null) { //modify collider points to snipping tringle //poll.points Vector2[] vert2d = new Vector2[mf.mesh.vertexCount]; for (int v = 0; v < mf.mesh.vertexCount; v++) { vert2d[v] = new Vector2(mf.mesh.vertices[v].x, mf.mesh.vertices[v].y); } Triangulator tr = new Triangulator(vert2d); int[] indices = tr.Triangulate(); Vector3[] vertices = new Vector3[indices.Length]; for (int i = 0; i < vertices.Length; i++) { vertices[i] = new Vector3(vertices[i].x, vertices[i].y, 0); } // Create the mesh Mesh msh = mf.mesh; msh.vertices = vertices; msh.triangles = indices; msh.RecalculateNormals(); msh.RecalculateBounds(); mf.mesh = msh; // mesh.mesh.triangles = newTriangles; } }
public void SetTile(GameObject field, GameObject terrain, string str) { this.meshField = Mesh.Instantiate(terrain.GetComponent<MeshFilter>().mesh) as Mesh; this.mfTileMeshFilter = (MeshFilter) field.GetComponent("MeshFilter"); this.mfTileMeshFilter.mesh = this.mesh; this.gameChildTile = new GameObject[4]; this.meshChildField = new Mesh[4]; this.mfChildMeshFilter = new MeshFilter[4]; GameObject tempField = GameObject.Instantiate(field) as GameObject; for(int i = 0; i < 4; ++i) { this.gameChildTile[i] = GameObject.Instantiate(tempField) as GameObject; this.gameChildTile[i].name = str + "_child_" + i; this.gameChildTile[i].transform.parent = field.transform; this.meshChildField[i] = Mesh.Instantiate(terrain.GetComponent<MeshFilter>().mesh) as Mesh; this.mfChildMeshFilter[i] = (MeshFilter) this.gameChildTile[i].GetComponent("MeshFilter"); this.mfChildMeshFilter[i].mesh = this.meshChildField[i]; this.mfChildMeshFilter[i].renderer.enabled = false; } Destroy(tempField); }
public FRenderLayer(FStage stage, FAtlas atlas, FShader shader) { _stage = stage; _atlas = atlas; _shader = shader; _expansionAmount = Futile.quadsPerLayerExpansion; _maxEmptyQuads = Futile.maxEmptyQuadsPerLayer; batchIndex = atlas.index*10000 + shader.index; _gameObject = new GameObject("FRenderLayer ("+_stage.name+")"); _transform = _gameObject.transform; _transform.parent = Futile.instance.gameObject.transform; _meshFilter = _gameObject.AddComponent<MeshFilter>(); _meshRenderer = _gameObject.AddComponent<MeshRenderer>(); _meshRenderer.castShadows = false; _meshRenderer.receiveShadows = false; _mesh = _meshFilter.mesh; _material = new Material(_shader.shader); _material.mainTexture = _atlas.texture; _meshRenderer.renderer.material = _material; _gameObject.active = false; ExpandMaxQuadLimit(Futile.startingQuadsPerLayer); UpdateTransform(); }
public void Initialize (Renderer parentRenderer) { this.parentRenderer = parentRenderer; parentFilter = parentRenderer.GetComponent<MeshFilter>(); mesh = parentFilter.sharedMesh; filter.sharedMesh = mesh; Debug.Log("Mesh: " + mesh); }
// Use this for initialization protected void Awake() { Filter = gameObject.GetComponent<MeshFilter>(); Coll = gameObject.GetComponent<MeshCollider>(); //past here is just to set up an example chunk //Blocks = new VoxBlock[ChunkSize, ChunkSize, ChunkSize]; for (var x = 0; x < World.ChunkSize; x++) { for (var y = 0; y < World.ChunkSize; y++) { for (var z = 0; z < World.ChunkSize; z++) { Blocks[x, y, z] = new Block(Color.white) { BlockType = VoxBlockType.Empty }; } } } //Blocks[1, 14, 1] = new VoxBlock(); //Blocks[3, 5, 2] = new VoxBlock(); //Blocks[4, 5, 2] = new VoxBlock(); //UpdateChunk(); }
void Start() { mf_ = GetComponent<MeshFilter>(); mr_ = GetComponent<MeshRenderer>(); mf_.sharedMesh = Explosion.Instance.getMesh(); mr_.sharedMaterial = Explosion.Instance.getMaterial(); }
void OnEnable () { //Get target MeshFilter targetMeshFilter = (target as MeshFilter); if (menuExpanded) { ejmmesh = new EJMMesh(targetMeshFilter); LoadCurrentEditor(); } //LOAD ICONS OpenGUI = new GUIContent(Resources.Load("Icons/wrench_icon") as Texture2D, "Edit"); if (OpenGUI.image == null){OpenGUI.text = "EDIT";} OpenUniqueGUI = new GUIContent(Resources.Load("Icons/wrench_plus_icon") as Texture2D, "Edit as Unique"); if (OpenUniqueGUI.image == null){OpenUniqueGUI.text = "EDIT";} CloseGUI = new GUIContent(Resources.Load("Icons/exit_icon") as Texture2D, "Save and Exit"); if (CloseGUI.image == null){CloseGUI.text = "DONE";} ObjectGUI = new GUIContent (Resources.Load("Icons/object_icon") as Texture2D, "Object Tools"); if (ObjectGUI.image == null){ObjectGUI.text = "OBJ";} VertexGUI = new GUIContent (Resources.Load("Icons/vertex_icon") as Texture2D, "Vertex Tools"); if (VertexGUI.image == null){VertexGUI.text = "VERT";} TriangleGUI = new GUIContent (Resources.Load("Icons/triangle_icon") as Texture2D, "Triangle Tools"); if (TriangleGUI.image == null){TriangleGUI.text = "TRIS";} NormalGUI = new GUIContent(Resources.Load("Icons/normal_icon") as Texture2D, "Normal Tools"); if (NormalGUI.image == null){NormalGUI.text = "NORM";} UVsGUI = new GUIContent(Resources.Load("Icons/uv_icon") as Texture2D, "UV Tools"); if (UVsGUI.image == null){UVsGUI.text = "UVs";} PrimitivesGUI = new GUIContent(Resources.Load("Icons/primitives_icon") as Texture2D, "Primitives"); if (PrimitivesGUI.image == null){PrimitivesGUI.text = "PRIM";} RevertGUI = new GUIContent(Resources.Load("Icons/undo_icon") as Texture2D, "Revert Mesh"); if (RevertGUI.image == null){RevertGUI.text = "UNDO";} ToolbarIcons = new GUIContent[6]{ObjectGUI, VertexGUI, TriangleGUI, NormalGUI, UVsGUI, PrimitivesGUI}; }
/// <summary> /// Reads all necessary mesh information /// </summary> public void ReadMesh() { Hashtable Hash=new Hashtable(); List<Vector3> pts = new List<Vector3>(); if (Mesh != mOldMesh || Transform.rotation != mOldRot || Scale != mOldScale) { if (Mesh) { int[] tris = Mesh.sharedMesh.triangles; Vector3[] verts = Mesh.sharedMesh.vertices; for (int i = 0; i < verts.Length; i++) verts[i].Scale(Scale); for (int t = 0; t < tris.Length; t += 3) { if (!Hash.ContainsKey(Key(tris[t], tris[t + 1]))) { Hash.Add(Key(tris[t], tris[t + 1]), null); pts.Add(verts[tris[t]]); pts.Add(verts[tris[t + 1]]); } if (!Hash.ContainsKey(Key(tris[t + 1], tris[t + 2]))) { Hash.Add(Key(tris[t + 1], tris[t + 2]), null); pts.Add(verts[tris[t + 1]]); pts.Add(verts[tris[t + 2]]); } if (!Hash.ContainsKey(Key(tris[t + 2], tris[t]))) { Hash.Add(Key(tris[t + 2], tris[t]), null); pts.Add(verts[tris[t + 2]]); pts.Add(verts[tris[t]]); } } } mOldMesh = Mesh; mOldRot = Transform.rotation; mOldScale = Scale; Points = pts.ToArray(); } }
//combines single mesh into the base mesh public static void combineMeshes(GameObject addMeshObject, GameObject baseMeshObject) { startPosition = baseMeshObject.transform.position; baseMeshObject.transform.position = new Vector3(0,0,0); addMesh = addMeshObject.GetComponent<MeshFilter>(); baseMesh = baseMeshObject.GetComponent<MeshFilter>(); if (baseMesh == null) { baseMesh.mesh = addMesh.mesh; baseMeshObject.transform.position = startPosition; return; } combine[0].mesh = addMesh.sharedMesh; combine[0].transform = addMesh.transform.localToWorldMatrix; combine[1].mesh = baseMesh.sharedMesh; combine[1].transform = baseMesh.transform.localToWorldMatrix; baseMeshObject.transform.GetComponent<MeshFilter>().mesh = new Mesh(); baseMeshObject.transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine,true); baseMeshObject.transform.gameObject.active = true; baseMeshObject.transform.position = startPosition; }
public static string MeshToString(MeshFilter mf) { Mesh m = mf.mesh; //Material[] mats = mf.GetComponent<Renderer>().sharedMaterials; StringBuilder sb = new StringBuilder(); sb.Append("g ").Append(mf.name).Append("\n"); foreach (Vector3 v in m.vertices) { sb.Append(string.Format("v {0} {1} {2}\n", v.x, v.y, v.z)); } sb.Append("\n"); foreach (Vector3 v in m.normals) { sb.Append(string.Format("vn {0} {1} {2}\n", v.x, v.y, v.z)); } sb.Append("\n"); foreach (Vector3 v in m.uv) { sb.Append(string.Format("vt {0} {1}\n", v.x, v.y)); } sb.Append("\n"); int[] triangles = m.GetTriangles(0); for (int i = 0; i < triangles.Length; i += 3) { sb.Append(string.Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", triangles[i] + 1, triangles[i + 1] + 1, triangles[i + 2] + 1)); } return sb.ToString(); }
void Update () { // When no button is pressed we update the mesh collider if (!Input.GetMouseButton (0)) { // Apply collision mesh when we let go of button ApplyMeshCollider(); return; } RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); if (Physics.Raycast (ray, out hit)) { MeshFilter filter = hit.collider.GetComponent<MeshFilter> (); if (filter) { if (filter != unappliedMesh) { ApplyMeshCollider(); unappliedMesh = filter; } Vector3 localPoint = filter.transform.InverseTransformPoint(hit.point); ExpandMesh(filter.mesh, localPoint, pull, radius); } } }
public void ManualUpdate(Mesh mesh, Material outerMaterial, float outerScale) { if (Corona != null) { if (MeshFilter == null) MeshFilter = gameObject.AddComponent<MeshFilter>(); if (MeshRenderer == null) MeshRenderer = gameObject.AddComponent<MeshRenderer>(); if (MeshFilter.sharedMesh != mesh) { SgtHelper.BeginStealthSet(MeshFilter); { MeshFilter.sharedMesh = mesh; } SgtHelper.EndStealthSet(); } if (MeshRenderer.sharedMaterial != outerMaterial) { SgtHelper.BeginStealthSet(MeshRenderer); { MeshRenderer.sharedMaterial = outerMaterial; } SgtHelper.EndStealthSet(); } SgtHelper.SetLocalScale(transform, outerScale); } }
// Use this for initialization void Start () { m_Creature = PlayerPrefs.GetString("m_Character" + m_PlayerProperty); m_Appearance = GetComponent<MeshFilter>(); rb_MyRigidBody = this.GetComponent<Rigidbody>(); switch (m_Creature) { case "Cochon": m_Appearance.mesh = s_VisuArray.a_MeshArray[0]; break; case "Paresseux": m_Appearance.mesh = s_VisuArray.a_MeshArray[1]; break; case "Mouton": m_Appearance.mesh = s_VisuArray.a_MeshArray[2]; break; case "Canard": m_Appearance.mesh = s_VisuArray.a_MeshArray[3]; break; } }
void Start() { //renderer = gameObject.AddComponent<MeshRenderer>(); //renderer.material = SetMaterial(); mesh = gameObject.AddComponent<MeshFilter>();// = mesh = new MeshFilter(); mesh.mesh = CreateQuad(); }
void Start() { filter = gameObject.GetComponent<MeshFilter>(); coll = gameObject.GetComponent<MeshCollider>(); //past here is just to set up an example chunk blocks = new Block[chunkSize, chunkSize, chunkSize]; for (int x = 0; x < chunkSize; x++) { for (int y = 0; y < chunkSize; y++) { for (int z = 0; z < chunkSize; z++) { blocks[x, y, z] = new BlockAir(); } } } blocks[1, 1, 1] = new Block(); blocks[1, 2, 1] = new Block(); blocks[1, 2, 2] = new Block(); blocks[2, 2, 2] = new Block(); UpdateChunk(); }
public VoronoiDiagram(MeshFilter mesh, Transform transform) { _initial = new Triangle(new Pnt(-10000, -10000), new Pnt(10000, -10000), new Pnt(0, 10000)); _delaunay = new Triangulation(_initial); _mesh = mesh; _transform = transform; }
public void ManualUpdate(Mesh mesh, Material material) { if (Jovian != null) { if (MeshFilter == null) MeshFilter = gameObject.AddComponent<MeshFilter>(); if (MeshRenderer == null) MeshRenderer = gameObject.AddComponent<MeshRenderer>(); if (MeshFilter.sharedMesh != mesh) { SgtHelper.BeginStealthSet(MeshFilter); { MeshFilter.sharedMesh = mesh; } SgtHelper.EndStealthSet(); } if (MeshRenderer.sharedMaterial != material) { SgtHelper.BeginStealthSet(MeshRenderer); { MeshRenderer.sharedMaterial = material; } SgtHelper.EndStealthSet(); } } }
public BoidController(MeshFilter meshFilter) { template = MeshDraft.Tetrahedron(0.3f); // Avoid vertex count overflow swarmCount = Mathf.Min(65000/template.vertices.Count, swarmCount); // Optimization trick: in each frame we simulate only small percent of all boids simulationUpdate = Mathf.RoundToInt(swarmCount*simulationPercent); int vertexCount = swarmCount*template.vertices.Count; draft = new MeshDraft { name = "Boids", vertices = new List<Vector3>(vertexCount), triangles = new List<int>(vertexCount), normals = new List<Vector3>(vertexCount), uv = new List<Vector2>(vertexCount), colors = new List<Color>(vertexCount) }; for (var i = 0; i < swarmCount; i++) { boids.Add(new Boid()); draft.Add(template); } mesh = draft.ToMesh(); mesh.MarkDynamic(); meshFilter.mesh = mesh; }
static public int set_sharedMesh(IntPtr l) { UnityEngine.MeshFilter o = (UnityEngine.MeshFilter)checkSelf(l); UnityEngine.Mesh v; checkType(l, 2, out v); o.sharedMesh = v; return(0); }
/// <summary> /// Write the specified value using the writer. /// </summary> /// <param name="value">Value.</param> /// <param name="writer">Writer.</param> public override void Write(object value, ISaveGameWriter writer) { UnityEngine.MeshFilter meshFilter = (UnityEngine.MeshFilter)value; writer.WriteProperty("mesh", meshFilter.mesh); writer.WriteProperty("sharedMesh", meshFilter.sharedMesh); writer.WriteProperty("tag", meshFilter.tag); writer.WriteProperty("name", meshFilter.name); writer.WriteProperty("hideFlags", meshFilter.hideFlags); }
static public int get_mesh(IntPtr l) { try { UnityEngine.MeshFilter self = (UnityEngine.MeshFilter)checkSelf(l); pushValue(l, self.mesh); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_sharedMesh(IntPtr l) { try { UnityEngine.MeshFilter self = (UnityEngine.MeshFilter)checkSelf(l); pushValue(l, self.sharedMesh); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int constructor(IntPtr l) { try { UnityEngine.MeshFilter o; o = new UnityEngine.MeshFilter(); pushValue(l, o); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { UnityEngine.MeshFilter o; o = new UnityEngine.MeshFilter(); pushValue(l, o); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_mesh(IntPtr l) { try { UnityEngine.MeshFilter self = (UnityEngine.MeshFilter)checkSelf(l); UnityEngine.Mesh v; checkType(l, 2, out v); self.mesh = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { LuaDLL.lua_remove(l, 1); UnityEngine.MeshFilter o; if (matchType(l, 1)) { o = new UnityEngine.MeshFilter(); pushObject(l, o); return(1); } LuaDLL.luaL_error(l, "New object failed."); return(0); }
public PPMesh(UnityEngine.MeshFilter meshFilter, Transform transform) { if (meshFilter.sharedMesh.name.Contains(meshName)) { FromUnityMesh(meshFilter.sharedMesh, transform); } else { var mesh = Object.Instantiate(meshFilter.sharedMesh) as Mesh; mesh.name += "[pp_mesh_edit]"; meshFilter.mesh = mesh; FromUnityMesh(mesh, transform); } }
static public int set_sharedMesh(IntPtr l) { try { UnityEngine.MeshFilter self = (UnityEngine.MeshFilter)checkSelf(l); UnityEngine.Mesh v; checkType(l, 2, out v); self.sharedMesh = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_sharedMesh(IntPtr l) { try { UnityEngine.MeshFilter self = (UnityEngine.MeshFilter)checkSelf(l); UnityEngine.Mesh v; checkType(l, 2, out v); self.sharedMesh = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
private void LazyIntialize() { if (this.buffers == null) { this.buffers = new MeshRendererBuffers(); this.buffers.Initialize(); if (this.meshGenerator == null) { this.meshGenerator = new Spine.Unity.MeshGenerator(); this.meshFilter = base.GetComponent <UnityEngine.MeshFilter>(); this.meshRenderer = base.GetComponent <UnityEngine.MeshRenderer>(); this.currentInstructions.Clear(); } } }
static void MeshFilter_sharedMesh(JSVCall vc) { if (vc.bGet) { UnityEngine.MeshFilter _this = (UnityEngine.MeshFilter)vc.csObj; var result = _this.sharedMesh; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.Mesh arg0 = (UnityEngine.Mesh)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.MeshFilter _this = (UnityEngine.MeshFilter)vc.csObj; _this.sharedMesh = arg0; } }
public StaticModel(UnityEngine.MeshRenderer renderer, UnityEngine.MeshFilter filter) : base(renderer) { material = ResourceCache.Instance.GetMaterial(renderer.sharedMaterial, renderer); model = ResourceCache.Instance.GetModel(filter.sharedMesh, renderer); castShadows = renderer.shadowCastingMode != UnityEngine.Rendering.ShadowCastingMode.Off; if (renderer.lightmapIndex >= 0) { lightMask = (int)LightmapBakeType.Realtime; } else { lightMask = (int)LightmapBakeType.Realtime | (int)LightmapBakeType.Mixed; } }
static int get_mesh(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.MeshFilter obj = (UnityEngine.MeshFilter)o; UnityEngine.Mesh ret = obj.mesh; ToLua.PushSealed(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index mesh on a nil value")); } }
void Start() { Model curModel = this.gameObject.GetComponentInChildren <Model>(); Vec3 pos = this.transform.position; int x = 1 & (int)pos.x; int y = 1 & (int)pos.y; int z = 1 & (int)pos.z; if ((z == 0 && x == y) || (z == 1 && x != y)) { curModel.mesh = modelA; } else { curModel.mesh = modelB; } }
static int set_sharedMesh(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.MeshFilter obj = (UnityEngine.MeshFilter)o; UnityEngine.Mesh arg0 = (UnityEngine.Mesh)ToLua.CheckObject(L, 2, typeof(UnityEngine.Mesh)); obj.sharedMesh = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index sharedMesh on a nil value")); } }
static int get_sharedMesh(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.MeshFilter obj = (UnityEngine.MeshFilter)o; UnityEngine.Mesh ret = obj.sharedMesh; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index sharedMesh on a nil value" : e.Message)); } }
/// <summary> /// Read the data into the specified value. /// </summary> /// <param name="value">Value.</param> /// <param name="reader">Reader.</param> public override void ReadInto(object value, ISaveGameReader reader) { UnityEngine.MeshFilter meshFilter = (UnityEngine.MeshFilter)value; foreach (string property in reader.Properties) { switch (property) { case "mesh": if (meshFilter.mesh == null) { meshFilter.mesh = reader.ReadProperty <UnityEngine.Mesh> (); } else { reader.ReadIntoProperty <UnityEngine.Mesh> (meshFilter.mesh); } break; case "sharedMesh": if (meshFilter.sharedMesh == null) { meshFilter.sharedMesh = reader.ReadProperty <UnityEngine.Mesh> (); } else { reader.ReadIntoProperty <UnityEngine.Mesh> (meshFilter.sharedMesh); } break; case "tag": meshFilter.tag = reader.ReadProperty <System.String> (); break; case "name": meshFilter.name = reader.ReadProperty <System.String> (); break; case "hideFlags": meshFilter.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> (); break; } } }
static int _CreateUnityEngine_MeshFilter(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { UnityEngine.MeshFilter obj = new UnityEngine.MeshFilter(); ToLua.PushSealed(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.MeshFilter.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static void componentSerialize(string ser) { GameObject gameObject = null; MarkerFlag objMarker = deserializeMarkerFlag(ref ser); int hashLoc = genHashCode(objMarker.id); int xLoc = hashLoc % 10; int yLoc = hashLoc % 100; MarkerFlag thisFlag = findInList(objMarker.id, xLoc, yLoc); if (thisFlag == null) //Make a new game object with given flag if you need to { gameObject = new GameObject(); thisFlag = gameObject.AddComponent <MarkerFlag>(); } else { gameObject = thisFlag.gameObject; } thisFlag.id = objMarker.id; thisFlag.parentID = objMarker.parentID; thisFlag.isLocked = objMarker.isLocked; if (thisFlag.parentID != "_") { int parentHash = genHashCode(thisFlag.parentID); int xParent = parentHash % 10; int yParent = parentHash % 100; MarkerFlag parentFlag = findInList(thisFlag.parentID, xParent, yParent); if (parentFlag != null) { gameObject.transform.SetParent(parentFlag.gameObject.transform); } else { gameObject.transform.SetParent(null); } } else { gameObject.transform.SetParent(null); } gameObject.name = deserializeString(ref ser); gameObject.tag = deserializeString(ref ser); gameObject.layer = deserializeInt(ref ser); gameObject.isStatic = deserializeBool(ref ser); while (ser.Length > 0) { string tag = deserializeString(ref ser); //Identifies the component type if (tag == "transform") { UnityEngine.Transform trans = gameObject.transform; trans.position = deserializeVector3(ref ser); trans.rotation = deserializeQuaternion(ref ser); trans.localScale = deserializeVector3(ref ser); if (expectedObjs > -1) { thisFlag.ogPos = trans.position; thisFlag.ogRot = trans.rotation; thisFlag.ogScale = trans.localScale; } } else if (tag == "boxCollider") { UnityEngine.BoxCollider col = gameObject.GetComponent <UnityEngine.BoxCollider>(); if (col == null) { col = gameObject.AddComponent <UnityEngine.BoxCollider>(); } col.center = deserializeVector3(ref ser); col.size = deserializeVector3(ref ser); col.isTrigger = deserializeBool(ref ser); } else if (tag == "sphereCollider") { UnityEngine.SphereCollider col = gameObject.GetComponent <UnityEngine.SphereCollider>(); if (col == null) { col = gameObject.AddComponent <UnityEngine.SphereCollider>(); } col.center = deserializeVector3(ref ser); col.radius = deserializeFloat(ref ser); col.isTrigger = deserializeBool(ref ser); } else if (tag == "capsuleCollider") { UnityEngine.CapsuleCollider col = gameObject.GetComponent <UnityEngine.CapsuleCollider>(); if (col == null) { col = gameObject.AddComponent <UnityEngine.CapsuleCollider>(); } col.center = deserializeVector3(ref ser); col.radius = deserializeFloat(ref ser); col.height = deserializeFloat(ref ser); col.direction = deserializeInt(ref ser); col.isTrigger = deserializeBool(ref ser); } else if (tag == "rigidbody") { UnityEngine.Rigidbody col = gameObject.GetComponent <UnityEngine.Rigidbody>(); if (col == null) { col = gameObject.AddComponent <UnityEngine.Rigidbody>(); } col.mass = deserializeFloat(ref ser); col.drag = deserializeFloat(ref ser); col.angularDrag = deserializeFloat(ref ser); col.interpolation = (RigidbodyInterpolation)deserializeInt(ref ser); col.constraints = (RigidbodyConstraints)deserializeInt(ref ser); col.useGravity = deserializeBool(ref ser); col.isKinematic = deserializeBool(ref ser); col.detectCollisions = deserializeBool(ref ser); } else if (tag == "camera") { UnityEngine.Camera cam = gameObject.GetComponent <UnityEngine.Camera>(); if (cam == null) { cam = gameObject.AddComponent <UnityEngine.Camera>(); } cam.clearFlags = (CameraClearFlags)deserializeInt(ref ser); cam.backgroundColor = deserializeColor(ref ser); cam.cullingMask = deserializeInt(ref ser); cam.nearClipPlane = deserializeFloat(ref ser); cam.farClipPlane = deserializeFloat(ref ser); cam.rect = deserializeRect(ref ser); cam.renderingPath = (RenderingPath)deserializeInt(ref ser); cam.allowHDR = deserializeBool(ref ser); cam.allowMSAA = deserializeBool(ref ser); cam.useOcclusionCulling = deserializeBool(ref ser); cam.depth = deserializeFloat(ref ser); cam.fieldOfView = deserializeFloat(ref ser); cam.targetDisplay = deserializeInt(ref ser); } else if (tag == "light") { UnityEngine.Light li = gameObject.GetComponent <UnityEngine.Light>(); if (li == null) { li = gameObject.AddComponent <UnityEngine.Light>(); } li.type = (LightType)deserializeInt(ref ser); li.shadows = (LightShadows)deserializeInt(ref ser); li.renderMode = (LightRenderMode)deserializeInt(ref ser); li.cullingMask = deserializeInt(ref ser); li.color = deserializeColor(ref ser); li.intensity = deserializeFloat(ref ser); li.cookieSize = deserializeFloat(ref ser); } else if (tag == "meshfilter") { UnityEngine.MeshFilter meshFilter = gameObject.GetComponent <UnityEngine.MeshFilter>(); if (meshFilter == null) { meshFilter = gameObject.AddComponent <UnityEngine.MeshFilter>(); } string filePath = deserializeString(ref ser); string meshName = deserializeString(ref ser); UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(filePath); for (int x = 0; x < assets.Length; ++x) { if (assets[x].name == meshName) { gameObject.GetComponent <UnityEngine.MeshFilter>().mesh = assets[x] as UnityEngine.Mesh; break; } } } else if (tag == "meshRenderer") { UnityEngine.MeshRenderer gOMeshRenderer = gameObject.GetComponent <UnityEngine.MeshRenderer>(); if (gOMeshRenderer == null) { gOMeshRenderer = gameObject.AddComponent <UnityEngine.MeshRenderer>(); } gOMeshRenderer.lightProbeUsage = (UnityEngine.Rendering.LightProbeUsage)deserializeInt(ref ser); gOMeshRenderer.reflectionProbeUsage = (UnityEngine.Rendering.ReflectionProbeUsage)deserializeInt(ref ser); gOMeshRenderer.shadowCastingMode = (UnityEngine.Rendering.ShadowCastingMode)deserializeInt(ref ser); gOMeshRenderer.receiveShadows = deserializeBool(ref ser); gOMeshRenderer.motionVectorGenerationMode = (UnityEngine.MotionVectorGenerationMode)deserializeInt(ref ser); //Light map static junk deserializeBool(ref ser); string materialsList = deserializeString(ref ser); List <Material> renderMaterials = new List <Material>(); if (materialsList.Length > 1) { while (materialsList != "") { int length = materialsList.IndexOf(","); if (length > 0) { string ret = materialsList.Substring(0, length); materialsList = materialsList.Remove(0, length + 1); Material newMat = null; if (ret == "Default-Material" || ret == "" || ret == "Resources/unity_builtin_extra") { newMat = AssetDatabase.GetBuiltinExtraResource <Material>("Default-Diffuse.mat"); } else { newMat = (Material)AssetDatabase.LoadAssetAtPath(ret, typeof(Material)); } renderMaterials.Add(newMat); } } if (renderMaterials.Count > 0) { gOMeshRenderer.GetComponent <Renderer>().materials = renderMaterials.ToArray(); } } } else if (tag == "guilayer") { UnityEngine.GUILayer gOGuiLayer = gameObject.GetComponent <GUILayer>(); if (gOGuiLayer == null) { gOGuiLayer = gameObject.AddComponent <GUILayer>(); } } else if (tag == "flarelayer") { UnityEngine.FlareLayer gOFlareLayer = gameObject.GetComponent <FlareLayer>(); if (gOFlareLayer == null) { gOFlareLayer = gameObject.AddComponent <FlareLayer>(); } } else if (tag == "audiolistener") { UnityEngine.AudioListener gOAudioListener = gameObject.GetComponent <AudioListener>(); if (gOAudioListener == null) { gOAudioListener = gameObject.AddComponent <AudioListener>(); } } else { Debug.Log("Unkown Componenet Type " + tag); } } addToMap(thisFlag); }
public static string serialize(GameObject obj) { string serialized = ""; //Message.GO_UPDATE.ToString(); serMarkerFlag serMarker = new serMarkerFlag(); //Put the marker flag info on the string first !!! serMarker.flag = obj.GetComponent <MarkerFlag>(); if (obj.transform.parent == null) { serMarker.flag.parentID = "__"; } else { serMarker.flag.parentID = obj.transform.parent.GetComponent <MarkerFlag>().id; } string flagData = new string(serMarker.toChar()); serialized += flagData; int hashLoc = genHashCode(serMarker.flag.id); int xLoc = hashLoc % 10; int yLoc = hashLoc % 100; //TODO check location if it already is there objectMap[xLoc, yLoc].Add(serMarker.flag); serialized += obj.name + "|"; serialized += obj.tag + "|"; serialized += obj.layer + "|"; serialized += obj.isStatic + "|"; Component[] comps; comps = obj.GetComponents <Component>(); for (int i = 0; i < comps.Length; i++) { if (comps[i] != null) { if (comps[i].GetType() == typeof(UnityEngine.Transform)) { UnityEngine.Transform newTransform = comps[i] as UnityEngine.Transform; Transform serNewTransform = new Transform(); serNewTransform.pos = newTransform.position; serNewTransform.rot = newTransform.rotation; serNewTransform.scale = newTransform.localScale; string transformString = new string(serNewTransform.toChar()); serialized += transformString; } else if (comps[i].GetType() == typeof(UnityEngine.BoxCollider)) { UnityEngine.BoxCollider newBoxCollider = comps[i] as UnityEngine.BoxCollider; BoxCollider serNewBoxCollider = new BoxCollider(); serNewBoxCollider.center = newBoxCollider.center; serNewBoxCollider.size = newBoxCollider.size; serNewBoxCollider.isTrigger = newBoxCollider.isTrigger; string boxColliderString = new string(serNewBoxCollider.toChar()); serialized += boxColliderString; } else if (comps[i].GetType() == typeof(UnityEngine.SphereCollider)) { UnityEngine.SphereCollider newSphereCollider = comps[i] as UnityEngine.SphereCollider; SphereCollider serNewSphereCollider = new SphereCollider(); serNewSphereCollider.center = newSphereCollider.center; serNewSphereCollider.radius = newSphereCollider.radius; serNewSphereCollider.isTrigger = newSphereCollider.isTrigger; string sphereColliderString = new string(serNewSphereCollider.toChar()); serialized += sphereColliderString; } else if (comps[i].GetType() == typeof(UnityEngine.CapsuleCollider)) { UnityEngine.CapsuleCollider newCapsuleCollider = comps[i] as UnityEngine.CapsuleCollider; CapsuleCollider serNewCapsuleCollider = new CapsuleCollider(); serNewCapsuleCollider.center = newCapsuleCollider.center; serNewCapsuleCollider.radius = newCapsuleCollider.radius; serNewCapsuleCollider.height = newCapsuleCollider.height; serNewCapsuleCollider.directionAxis = newCapsuleCollider.direction; serNewCapsuleCollider.isTrigger = newCapsuleCollider.isTrigger; string capsuleColliderString = new string(serNewCapsuleCollider.toChar()); serialized += capsuleColliderString; } else if (comps[i].GetType() == typeof(UnityEngine.Rigidbody)) { UnityEngine.Rigidbody newRigidBody = comps[i] as UnityEngine.Rigidbody; RigidBody serNewRigidBody = new RigidBody(); serNewRigidBody.mass = newRigidBody.mass; serNewRigidBody.drag = newRigidBody.drag; serNewRigidBody.angularDrag = newRigidBody.angularDrag; serNewRigidBody.interpolate = (int)newRigidBody.interpolation; serNewRigidBody.collisionDetection = newRigidBody.detectCollisions; serNewRigidBody.freeze = (int)newRigidBody.constraints; serNewRigidBody.isKinematic = newRigidBody.isKinematic; serNewRigidBody.useGravity = newRigidBody.useGravity; serNewRigidBody.collisionDetection = newRigidBody.detectCollisions; string rigidBodyString = new string(serNewRigidBody.toChar()); serialized += rigidBodyString; } else if (comps[i].GetType() == typeof(UnityEngine.Camera)) { UnityEngine.Camera newCamera = comps[i] as UnityEngine.Camera; Camera serNewCamera = new Camera(); serNewCamera.clearFlags = (int)newCamera.clearFlags; serNewCamera.background = newCamera.backgroundColor; serNewCamera.cullingMask = newCamera.cullingMask; serNewCamera.projection = newCamera.projectionMatrix.ToString(); serNewCamera.near = newCamera.nearClipPlane; serNewCamera.far = newCamera.farClipPlane; serNewCamera.viewportRect = newCamera.rect; serNewCamera.renderingPath = (int)newCamera.renderingPath; serNewCamera.HDR = newCamera.allowHDR; serNewCamera.MSAA = newCamera.allowMSAA; serNewCamera.occlusionCulling = newCamera.useOcclusionCulling; serNewCamera.depth = newCamera.depth; serNewCamera.fov = newCamera.fieldOfView; serNewCamera.targetDisplay = newCamera.targetDisplay; string cameraString = new string(serNewCamera.toChar()); serialized += cameraString; } else if (comps[i].GetType() == typeof(UnityEngine.MeshFilter)) { //Gather Meshfilter information on current GO UnityEngine.MeshFilter gOMeshFilter = comps[i] as UnityEngine.MeshFilter; Mesh gOMesh = gOMeshFilter.sharedMesh; //Pack data into our meshfilter object MeshFilter meshStruct = new MeshFilter(); meshStruct.filePath = AssetDatabase.GetAssetPath(gOMesh); meshStruct.meshName = gOMesh.name; //Convert the data into a string and add it to the overall data stream string sStream = new string(meshStruct.toChar()); serialized += sStream; } else if (comps[i].GetType() == typeof(UnityEngine.MeshRenderer)) { UnityEngine.MeshRenderer gOMeshRenderer = comps[i] as UnityEngine.MeshRenderer; //Pack data into our MeshRenderer obj MeshRenderer meshStruct = new MeshRenderer(); meshStruct.lightProbe = (int)gOMeshRenderer.lightProbeUsage; meshStruct.reflectionProbe = (int)gOMeshRenderer.reflectionProbeUsage; meshStruct.castShadows = (int)gOMeshRenderer.shadowCastingMode; meshStruct.receiveShadows = gOMeshRenderer.receiveShadows; meshStruct.motionVectors = (int)gOMeshRenderer.motionVectorGenerationMode; meshStruct.lightmapStatic = false; Material[] gOMaterials = gOMeshRenderer.sharedMaterials; for (int q = 0; q < gOMaterials.Length; ++q) { string materialPath = ""; if (gOMaterials[q] == null || gOMaterials[q].name == "Default-Material") { materialPath = "Default-Material"; } else { materialPath = AssetDatabase.GetAssetPath(gOMaterials[q]); } meshStruct.materialFiles.Add(materialPath); } string sStream = new string(meshStruct.toChar()); serialized += sStream; } else if (comps[i].GetType() == typeof(UnityEngine.Light)) { UnityEngine.Light newLight = comps[i] as UnityEngine.Light; Light serNewLight = new Light(); serNewLight.type = (int)newLight.type; serNewLight.shadows = (int)newLight.shadows; serNewLight.mode = (int)newLight.renderMode; serNewLight.cullingMask = newLight.cullingMask; serNewLight.color = newLight.color; serNewLight.intensity = newLight.intensity; serNewLight.cookie = newLight.cookieSize; string lightString = new string(serNewLight.toChar()); serialized += lightString; } else if (comps[i].GetType() == typeof(UnityEngine.GUILayer)) { UnityEngine.GUILayer newGuiLayer = comps[i] as UnityEngine.GUILayer; string lightString = "guilayer|"; serialized += lightString; } else if (comps[i].GetType() == typeof(UnityEngine.FlareLayer)) { UnityEngine.FlareLayer newGuiLayer = comps[i] as UnityEngine.FlareLayer; string lightString = "flarelayer|"; serialized += lightString; } else if (comps[i].GetType() == typeof(UnityEngine.AudioListener)) { UnityEngine.AudioListener newGuiLayer = comps[i] as UnityEngine.AudioListener; string lightString = "audiolistener|"; serialized += lightString; } } } return(serialized); }
/// <summary> /// Read the data using the reader. /// </summary> /// <param name="reader">Reader.</param> public override object Read(ISaveGameReader reader) { UnityEngine.MeshFilter meshFilter = SaveGameType.CreateComponent <UnityEngine.MeshFilter> (); ReadInto(meshFilter, reader); return(meshFilter); }
static public int get_sharedMesh(IntPtr l) { UnityEngine.MeshFilter o = (UnityEngine.MeshFilter)checkSelf(l); pushValue(l, o.sharedMesh); return(1); }
public override void Write(object obj, ES2Writer writer) { UnityEngine.MeshFilter data = (UnityEngine.MeshFilter)obj; // Add your writer.Write calls here. writer.Write(data.hideFlags); }
public override object Read(ES2Reader reader) { UnityEngine.MeshFilter data = GetOrCreate <UnityEngine.MeshFilter>(); Read(reader, data); return(data); }
public static void CombineGameObjects(GameObject[] gos, GameObject staticBatchRoot, bool isEditorPostprocessScene) { Matrix4x4 lhs = Matrix4x4.identity; Transform staticBatchRootTransform = null; if ((bool)staticBatchRoot) { lhs = staticBatchRoot.transform.worldToLocalMatrix; staticBatchRootTransform = staticBatchRoot.transform; } int num = 0; int num2 = 0; List <MeshSubsetCombineUtility.MeshInstance> list = new List <MeshSubsetCombineUtility.MeshInstance>(); List <MeshSubsetCombineUtility.SubMeshInstance> list2 = new List <MeshSubsetCombineUtility.SubMeshInstance>(); List <GameObject> list3 = new List <GameObject>(); Array.Sort(gos, new SortGO()); foreach (GameObject gameObject in gos) { MeshFilter meshFilter = gameObject.GetComponent(typeof(MeshFilter)) as MeshFilter; if (meshFilter == null) { continue; } Mesh sharedMesh = meshFilter.sharedMesh; if (sharedMesh == null || (!isEditorPostprocessScene && !sharedMesh.canAccess)) { continue; } Renderer component = meshFilter.GetComponent <Renderer>(); if (component == null || !component.enabled || component.staticBatchIndex != 0) { continue; } Material[] array = meshFilter.GetComponent <Renderer>().sharedMaterials; if (array.Any((Material m) => m != null && m.shader != null && m.shader.disableBatching != DisableBatchingType.False)) { continue; } if (num2 + meshFilter.sharedMesh.vertexCount > 64000) { MakeBatch(list, list2, list3, staticBatchRootTransform, num++); list.Clear(); list2.Clear(); list3.Clear(); num2 = 0; } MeshSubsetCombineUtility.MeshInstance item = default(MeshSubsetCombineUtility.MeshInstance); item.meshInstanceID = sharedMesh.GetInstanceID(); item.rendererInstanceID = component.GetInstanceID(); MeshRenderer meshRenderer = component as MeshRenderer; if (meshRenderer != null && meshRenderer.additionalVertexStreams != null) { item.additionalVertexStreamsMeshInstanceID = meshRenderer.additionalVertexStreams.GetInstanceID(); } item.transform = lhs * meshFilter.transform.localToWorldMatrix; item.lightmapScaleOffset = component.lightmapScaleOffset; item.realtimeLightmapScaleOffset = component.realtimeLightmapScaleOffset; list.Add(item); if (array.Length > sharedMesh.subMeshCount) { Debug.LogWarning("Mesh has more materials (" + array.Length + ") than subsets (" + sharedMesh.subMeshCount + ")", meshFilter.GetComponent <Renderer>()); Material[] array2 = new Material[sharedMesh.subMeshCount]; for (int j = 0; j < sharedMesh.subMeshCount; j++) { array2[j] = meshFilter.GetComponent <Renderer>().sharedMaterials[j]; } meshFilter.GetComponent <Renderer>().sharedMaterials = array2; array = array2; } for (int k = 0; k < Math.Min(array.Length, sharedMesh.subMeshCount); k++) { MeshSubsetCombineUtility.SubMeshInstance item2 = default(MeshSubsetCombineUtility.SubMeshInstance); item2.meshInstanceID = meshFilter.sharedMesh.GetInstanceID(); item2.vertexOffset = num2; item2.subMeshIndex = k; item2.gameObjectInstanceID = gameObject.GetInstanceID(); item2.transform = item.transform; list2.Add(item2); list3.Add(gameObject); } num2 += sharedMesh.vertexCount; } MakeBatch(list, list2, list3, staticBatchRootTransform, num); }
public override void Read(ES2Reader reader, object c) { UnityEngine.MeshFilter data = (UnityEngine.MeshFilter)c; // Add your reader.Read calls here to read the data into the object. data.hideFlags = reader.Read <UnityEngine.HideFlags>(); }