void RpcUpdateSpoiler(GameObject obj, int id, ColourStruct colour) { obj.transform.Find("Spoiler_Spawn").gameObject.GetComponent <MeshFilter>().sharedMesh = spoilerObject[id].partObjectPrefab.GetComponent <MeshFilter>().sharedMesh; if (obj.transform.Find("Spoiler_Spawn").gameObject.GetComponent <Renderer>() == null) { return; } MaterialPropertyBlock props = new MaterialPropertyBlock(); props.SetColor("_Color_Red", colour.redChannel); props.SetColor("_Color_Green", colour.greenChannel); props.SetColor("_Color_Blue", colour.blueChannel); props.SetColor("_Color_Alpha", colour.alphaChannel); obj.transform.Find("Spoiler_Spawn").GetComponent <Renderer>().SetPropertyBlock(props); }
void UpdatePreviewCar() { // Find the preview Car previewCar = GameObject.Find("PreviewCart"); // Update car colours GameObject carMesh = previewCar.transform.Find("Mesh_Vehicle").gameObject; ColourStruct colours = bodys[bodyID].colour; UpdatePartColour(carMesh, colours.redChannel, colours.blueChannel, colours.greenChannel, colours.alphaChannel); // Find the spoiler part GameObject spoilerSpawn = previewCar.transform.Find("Spoiler_Spawn").gameObject; // Update spoiler Mesh spoilerSpawn.GetComponent <MeshFilter>().sharedMesh = spoilers[spoilerID].partObjectPrefab.GetComponent <MeshFilter>().sharedMesh; // Update part colour colours = spoilers[spoilerID].colour; UpdatePartColour(spoilerSpawn, colours.redChannel, colours.blueChannel, colours.greenChannel, colours.alphaChannel); GameObject wheelParentObject = previewCar.transform.Find("Wheels_Spawn").gameObject; for (int i = 0; i < wheelParentObject.transform.childCount; i++) { GameObject wheelChild = wheelParentObject.transform.GetChild(i).gameObject; wheelChild.GetComponent <MeshFilter>().sharedMesh = wheels[wheelID].partObjectPrefab.GetComponent <MeshFilter>().sharedMesh; // Update the colour colours = wheels[wheelID].colour; UpdatePartColour(wheelChild, colours.redChannel, colours.blueChannel, colours.greenChannel, colours.alphaChannel); } // Update Character GameObject characterSpawn = previewCar.transform.Find("Character_Spawn").gameObject; characterSpawn.GetComponent <MeshFilter>().sharedMesh = characters[characterID].partObjectPrefab.GetComponentInChildren <MeshFilter>().sharedMesh; // Update the visual display of stats UpdateSliders(); }
void RpcUpdateWheels(GameObject obj, int id, ColourStruct colour) { GameObject wheelParentObject = obj.transform.Find("Wheels_Spawn").gameObject; for (int i = 0; i < wheelParentObject.transform.childCount; i++) { GameObject wheelChild = wheelParentObject.transform.GetChild(i).gameObject; wheelChild.GetComponent <MeshFilter>().sharedMesh = wheelsObject[id].partObjectPrefab.GetComponent <MeshFilter>().sharedMesh; // Change the colour if (wheelChild.GetComponent <Renderer>() == null) { return; } MaterialPropertyBlock props = new MaterialPropertyBlock(); props.SetColor("_Color_Red", colour.redChannel); props.SetColor("_Color_Green", colour.greenChannel); props.SetColor("_Color_Blue", colour.blueChannel); props.SetColor("_Color_Alpha", colour.alphaChannel); wheelChild.GetComponent <Renderer>().SetPropertyBlock(props); } }
void RpcUpdateVehicleColour(GameObject obj, ColourStruct colours) { // Update the vehicle colour for all the other players obj.GetComponentInChildren <ColourPicker>().colours = colours; }
public void CmdRequestColourChange(ColourStruct newColours) { vehicleColour = newColours; }