private void Waiting2r() { Thread.Sleep(20000); Mesh mesh = LoadAssets.LoadOBJMesh(this, "tire_rally.obj"); Texture2D mainTexture = LoadAssets.LoadTexture(this, "tires_rally.dds", false); GameObject[] array = GameObject.FindObjectsOfType <GameObject>(); for (int i = 0; i < array.Length; i++) { GameObject gameObject = array[i]; if (gameObject.name == "TireRally(Clone)") { gameObject.GetComponent <MeshFilter>().mesh = (mesh); gameObject.GetComponent <MeshRenderer>().material.mainTexture = (mainTexture); } } if (GameObject.Find("wheel rally fl(Clone)").activeSelf) { this.FLRIM = GameObject.Find("wheel rally fl(Clone)"); this.FRRIM = GameObject.Find("wheel rally fr(Clone)"); this.RLRIM = GameObject.Find("wheel rally rl(Clone)"); this.RRRIM = GameObject.Find("wheel rally rr(Clone)"); Mesh mesh2 = LoadAssets.LoadOBJMesh(this, "rim_rally.obj"); this.FLRIM.transform.GetComponent <MeshFilter>().mesh = (mesh2); this.FRRIM.transform.GetComponent <MeshFilter>().mesh = (mesh2); this.RLRIM.transform.GetComponent <MeshFilter>().mesh = (mesh2); this.RRRIM.transform.GetComponent <MeshFilter>().mesh = (mesh2); } }
/// <summary> /// Occurs on game load. /// </summary> public override void OnLoad() { // Written, 18.10.2018 // Called once, when mod is loading after game is fully loaded // Creating truck engine object. NOTE Mod-API excepts the gameobject to have both a rigidbody and a collider attached before passing the reference. GameObject truckEngineGo = LoadAssets.LoadOBJ(this, @"truck_engine.obj", rigidbody: true); truckEngineGo.name = "Truck Engine"; // Loading and assigning the texture for the object. Texture2D engineTexture = LoadAssets.LoadTexture(this, "Truck_Engine_Texture.png"); truckEngineGo.GetComponent <Renderer>().material.mainTexture = engineTexture; GameObject parent = GameObject.Find("SATSUMA(557kg, 248)"); // Creating trigger for truck engine. and assigning the local location and scale of the trigger related to the parent. (in this case the satsuma). Trigger trigger = new Trigger("TruckEngineTrigger", parent, new Vector3(0.0f, 1.3f, -0.3f), Quaternion.Euler(0, 0, 0), new Vector3(1f, 1f, 1f), false); // Creating a new instance of the truckengine. this.truckEngine = new TruckEngine( this.loadSaveData(), // The save data, as this is null, default save info will always be loaded. truckEngineGo, // The instance of the part to create. parent, // The parent for the part; the gameobject the part installs to. trigger, // The trigger for the part. new Vector3(0.0f, 0.63f, 1.5f), // The installed-position new Quaternion(0, 90, 90, 0)); // The installed-rotation ModConsole.Print(string.Format("{0} v{1}: Loaded.", this.Name, this.Version)); }
private void _initShop() { // Load the lightbulb box GameObject original = LoadAssets.LoadOBJ(this, "model\\box.obj", false, false); original.name = "new_lightbulb"; original.GetComponent <MeshRenderer>().material.mainTexture = LoadAssets.LoadTexture(this, "model\\box_d.png"); AudioSource audio = original.AddComponent <AudioSource>(); audio.clip = GameObject.Find("cash_register_2").GetComponent <AudioSource>().clip; audio.transform.parent = original.transform; audio.spatialBlend = 1.0f; audio.maxDistance = 10.0f; GameObject fBox = GameObject.Instantiate <GameObject>(original); original.transform.position = _teimoPos; original.transform.rotation = Quaternion.Euler(0.0f, 180.0f, 0.0f); MeshCollider coll = original.AddComponent <MeshCollider>(); coll.name = "replace lightbulb (300mk)(Clone)"; coll.convex = true; coll.isTrigger = true; _boxColliderTeimo = coll; fBox.transform.position = _fleetariPos; coll = fBox.AddComponent <MeshCollider>(); coll.name = "replace lightbulb (300mk)(Clone)"; coll.convex = true; coll.isTrigger = true; _boxColliderFleetari = coll; }
public override void OnLoad() { // Written, 23.09.2018 // Called once, when mod is loading after game is fully loaded // Creating Game Object. this.truckEngine = LoadAssets.LoadOBJ(this, @"truck_engine.obj", true, true); // Loading and assigning the texture for the object. this.engineTexture = LoadAssets.LoadTexture(this, "Truck_Engine_Texture.png"); this.truckEngine.GetComponent <Renderer>().material.mainTexture = this.engineTexture; // Naming the object. NOTE, name must follow naming convention of <ObjectName>(xxxxx) where <ObjectName> is the game objects name. this.truckEngine.name = "Truck Engine(xxxxx)"; // Spawning the game object to home. this.truckEngine.transform.position = new Vector3(-20.7f, 10, 10.9f); // Home Location (Outside Garage) this.truckEngine.transform.rotation = new Quaternion(0, 90, 90, 0); // The Rotation. // Allowing the object to be picked up. this.truckEngine.tag = "PART"; // Sending object to it's own layer. this.truckEngine.layer = LayerMask.NameToLayer(this.truckEngine.name); }
private void _initLight(SaveData saveData) { MeshCollider coll; MeshRenderer renderer; Texture2D tex_diff = LoadAssets.LoadTexture(this, "model\\floodlight_d.png"); // Floodlight base _base = LoadAssets.LoadOBJ(this, "model\\floodlight_base.obj", false, false); _base.name = "floodlight(Clone)"; _base.layer = LayerMask.NameToLayer("Parts"); _base.tag = "PART"; _base.transform.position = saveData.Pos; _base.transform.rotation = saveData.Rot; coll = _base.AddComponent <MeshCollider>(); coll.convex = true; coll.name = "floodlight(Clone)"; Rigidbody rb = _base.AddComponent <Rigidbody>(); rb.mass = 5.0f; rb.detectCollisions = true; rb.collisionDetectionMode = CollisionDetectionMode.Continuous; rb.isKinematic = false; renderer = _base.GetComponent <MeshRenderer>(); renderer.material.mainTexture = tex_diff; // Lamp cover _lamp = LoadAssets.LoadOBJ(this, "model\\floodlight_cover.obj", false, false); _lamp.name = "floodlight cover(Clone)"; _lamp.transform.parent = _base.transform; _lamp.transform.localPosition = new Vector3(0.0f, 0.22f, 0.0f); _lamp.transform.localEulerAngles = new Vector3(_pitch, 0.0f, 0.0f); _lampCollider = _lamp.AddComponent <MeshCollider>(); _lampCollider.convex = true; _lampCollider.isTrigger = true; renderer = _lamp.GetComponent <MeshRenderer>(); renderer.material.mainTexture = tex_diff; // Glass _glass = LoadAssets.LoadOBJ(this, "model\\floodlight_glass.obj", false, false); _glass.name = "floodlight glass(Clone)"; _glass.transform.parent = _lamp.transform; _glass.transform.localPosition = new Vector3(); _glass.transform.localRotation = new Quaternion(); _glassMaterial = _glass.GetComponent <MeshRenderer>().material; _glassMaterial.mainTexture = tex_diff; _glassMaterial.shader = Shader.Find("Standard"); // Switch _switch = GameObject.CreatePrimitive(PrimitiveType.Cube); _switch.name = "floodlight indicator(Clone)"; _switch.transform.parent = _lamp.transform; _switch.transform.localScale = new Vector3(0.03f, 0.01f, 0.01f); _switch.transform.localPosition = new Vector3(0.0f, 0.09f, 0.04f); _switch.transform.localRotation = new Quaternion(); _switch.AddComponent <Renderer>(); _switchMaterial = _switch.GetComponent <Renderer>().material; _switchMaterial.color = Color.red * 0.3f; GameObject.Destroy(_switch.GetComponent <Rigidbody>()); GameObject.Destroy(_switch.GetComponent <Collider>()); // Light _light = _lamp.AddComponent <Light>(); _light.type = LightType.Spot; _light.color = _lightColor; _light.intensity = _baseIntensity; _light.range = 20.0f; _light.spotAngle = 80.0f; _light.transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f); _light.renderMode = LightRenderMode.ForceVertex; _light.enabled = false; }