void Start() { roundController = FindObjectOfType <RoundController>(); roomContraller = FindObjectOfType <RoomContraller>(); miniMapUI = FindObjectOfType <MiniMapUI>(); newDi1 = Instantiate(minRoom) as GameObject; newDi1.GetComponent <RectTransform>().SetParent(MinMapPlane.transform); newDi1.GetComponent <RectTransform>().localPosition = showMPos; newDi2 = Instantiate(minRoom) as GameObject; newDi2.GetComponent <RectTransform>().SetParent(MinMapPlane.transform); // newDi2.GetComponent<RectTransform>().localPosition = show2Pos; newDi2.SetActive(false); newDi3 = Instantiate(minRoom) as GameObject; newDi3.GetComponent <RectTransform>().SetParent(MinMapPlane.transform); //newDi3.GetComponent<RectTransform>().localPosition = show1Pos; newDi3.SetActive(false); newDi4 = Instantiate(minRoom) as GameObject; newDi4.GetComponent <RectTransform>().SetParent(MinMapPlane.transform); // newDi4.GetComponent<RectTransform>().localPosition = show1Pos; newDi4.SetActive(false); newDi5 = Instantiate(minRoom) as GameObject; newDi5.GetComponent <RectTransform>().SetParent(MinMapPlane.transform); newDi5.SetActive(false); // newDi5.GetComponent<RectTransform>().localPosition = show1Pos; east = new int[] { 0, 0, 0 }; west = new int[] { 0, 0, 0 }; north = new int[] { 0, 0, 0 }; south = new int[] { 0, 0, 0 }; }
// Use this for initialization private void Start() { //Setting the global reference to this component if one doesn't already exist if (globalReference == null) { globalReference = this; } //If there's already a global reference, we destroy this component else { Destroy(this); } //Getting the reference to this object's sprite renderer this.ourSprite = this.GetComponent <Image>(); //Getting the file path for this game's map image string mapFilePath = Application.persistentDataPath + GameData.globalReference.saveFolder + "/Map.png"; //As long as we have the correct file directory the file will load and fill in the texture if (File.Exists(mapFilePath)) { //Loading the map png file as a new texture byte[] mapFileData = File.ReadAllBytes(mapFilePath); Texture2D mapTexture = new Texture2D(2, 2); mapTexture.LoadImage(mapFileData); //Creating a new sprite from the map texture to set as our object's sprite Sprite mapSprite = Sprite.Create(mapTexture, new Rect(0, 0, mapTexture.width, mapTexture.height), new Vector2(0, 0)); this.ourSprite.sprite = mapSprite; //Resizing our sprite size this.ourSprite.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mapTexture.height * this.mapShiftOnMove); this.ourSprite.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, mapTexture.width * this.mapShiftOnMove); //Setting the starting position of the image } }