Last active
May 19, 2019 16:21
-
-
Save ronyx69/7c1abc25644d4e789e65e0064808e8ea to your computer and use it in GitHub Desktop.
Copies mesh from a prop to a vehicle, don't use for vehicles with tyres.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copies mesh from a prop to a vehicle, don't use for vehicles with tyres. | |
var propname = "filename.Asset Name"; // filename.Asset Name | |
var prop = PrefabCollection<PropInfo>.FindLoaded(propname + "_Data"); | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo; | |
asset.m_mesh.vertices = prop.m_mesh.vertices; asset.m_mesh.triangles = prop.m_mesh.triangles; | |
asset.m_mesh.tangents = prop.m_mesh.tangents; asset.m_mesh.normals = prop.m_mesh.normals; | |
asset.m_mesh.uv = prop.m_mesh.uv; asset.m_mesh.bounds = prop.m_mesh.bounds; | |
asset.m_generatedInfo.m_size = prop.m_generatedInfo.m_size; | |
asset.m_generatedInfo.m_triangleArea = prop.m_generatedInfo.m_triangleArea; | |
asset.m_generatedInfo.m_uvmapArea = prop.m_generatedInfo.m_uvmapArea; | |
asset.m_generatedInfo.m_wheelBase = asset.m_generatedInfo.m_size.z * 0.6f; | |
asset.m_generatedInfo.m_wheelGauge = asset.m_generatedInfo.m_size.x * 0.5f; | |
if(asset.m_mesh.bounds.min.y < 0) asset.m_generatedInfo.m_negativeHeight = Math.Abs(asset.m_mesh.bounds.min.y); | |
else asset.m_generatedInfo.m_negativeHeight = 0; | |
Color nc = new Color32(0, 0, 1, 1); Color32 nc32 = new Color32(0, 0, 255, 255); | |
var colors = new Color[asset.m_mesh.vertices.Length]; var colors32 = new Color32[asset.m_mesh.vertices.Length]; | |
for(var i = 0; i < asset.m_mesh.vertices.Length; i++) { colors[i] = nc; colors32[i] = nc32; } | |
asset.m_mesh.colors = colors; asset.m_mesh.colors32 = colors32; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment