// Use this for initialization void Start() { instance = this; sr = GetComponent <SpriteRenderer> (); // sr: Global GroundController variable, ref for the Ground SpriteRenderer //Texture2D tex = (Texture2D) Resources.Load ("ground2"); Texture2D tex = (Texture2D)Resources.Load("ground1"); switch (GameManager.value) { case 0: tex = (Texture2D)Resources.Load("ground1"); break; case 1: tex = (Texture2D)Resources.Load("ground2"); break; case 2: tex = (Texture2D)Resources.Load("ground3"); break; case 3: tex = (Texture2D)Resources.Load("ground4"); break; case 4: tex = (Texture2D)Resources.Load("ground5"); break; } Debug.Log(GameManager.value + " Terrain type Selection"); //sr.sprite = GameManager.instance.Texture_sprite[GameManager.value]; //Texture2D tex = (Texture2D) Resources.Load (GameManager.instance.Terrain[GameManager.instance.value]); // Resources.Load ("filename") loads a file located // in Assets / Resources Texture2D tex_clone = (Texture2D)Instantiate(tex); // We created a Texture2D clone of tex so we did not change the original image sr.sprite = Sprite.Create(tex_clone, new Rect(0f, 0f, tex_clone.width, tex_clone.height), new Vector2(0.5f, 0.5f), 100f); Destroy(GetComponent <PolygonCollider2D> ()); gameObject.AddComponent <PolygonCollider2D>(); transp = new Color(0f, 0f, 0f, 0f); initSpriteDimensions(); }
// Use this for initialization void Awake() { terrainD = GetComponent <TerrainDestruction>(); }