SHARE
TWEET

Untitled

a guest Jul 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. using UnityEngine;
  3.  
  4.  
  5. public class ColliderLoader : MonoBehaviour
  6. {
  7.     public void colliderToMap()
  8.     {
  9.         foreach (GameObject gameObject in UnityEngine.Object.FindObjectsOfType(typeof(GameObject)))
  10.         {
  11.             if(gameObject.name == "JumpPark")
  12.             {
  13.                 GameObject gameObject2 = new GameObject("SpaceportMesh");
  14.                 gameObject2.transform.position = new Vector3(0f, 0.41f, 0f);
  15.                 Mesh mesh;
  16.                 Material material = gameObject.GetComponent<MeshRenderer>().sharedMaterial;
  17.                 mesh = gameObject.GetComponent<MeshFilter>().sharedMesh;
  18.                 gameObject2.AddComponent<MeshFilter>().sharedMesh = mesh;
  19.                 gameObject2.AddComponent<MeshCollider>().sharedMesh = mesh;
  20.                 gameObject2.GetComponent<MeshCollider>().isTrigger = false;
  21.                 gameObject2.GetComponent<MeshCollider>().convex = false;
  22.                 gameObject2.AddComponent<MeshRenderer>().sharedMaterial = material;
  23.                 Destroy(gameObject);
  24.             }
  25.         }
  26.     }
  27.     public void OnGUI()
  28.     {
  29.         if (GUI.Button(new Rect(50f, 100f, 200f, 20f), "LoadCollider")) {
  30.             this.colliderToMap();
  31.         }
  32.     }
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top