void Start() { foreach (GameObject rectangle in GameObject.FindGameObjectsWithTag("Rectangles")) { //if (rectangle.gameObject.name == "FocusRectangle") //FocusSprite = rectangle.GetComponent<FocusRectangleObject>(); if (rectangle.gameObject.name == "SelectionRectangle") { SelectionSprite = rectangle.GetComponent <SelectorScript>(); } else if (rectangle.gameObject.name == "GroupRectangle") { GroupSprite = rectangle.GetComponent <GroupRectangleScript>(); } } MouseEvents.Setup(gameObject); SelectedGroup = ScriptableObject.CreateInstance <UnitGroup>(); SelectedGroup.startGroup(); //scrolling = (GetComponent<Scrolling>()) ? GetComponent<Scrolling>() : null; //if (camera.name == null) //{ camera = Camera.main; //} Scale = new Vector2((camera.pixelRect.width / gameObject.guiTexture.texture.width), (camera.pixelRect.height / gameObject.guiTexture.texture.height)); //gameObject.guiTexture.pixelInset = new Rect(0, -camera.pixelHeight, camera.pixelWidth, camera.pixelHeight); //if (gameObject.GetComponent<GUIText>() == null) gameObject.AddComponent<GUIText>(); gameObject.guiText.pixelOffset = new Vector2(-Camera.main.pixelWidth / 2 + 25 * Scale.x, Camera.main.pixelHeight / 2 - 80 * Scale.y); MapViewArea = new Rect(20 * Scale.x, 20 * Scale.y, 1675 * Scale.x, 1047 * Scale.y); MainGuiArea = new Rect(1716 * Scale.x, 20 * Scale.y, 184 * Scale.x, 1047 * Scale.y); gameObject.guiText.fontSize = (int)(40f * Scale.x + 0.5f); //guiTexture.pixelInset = MapViewArea; //guiTexture.guiTexture.border.left = (int)(20f * Scale.x); //guiTexture.guiTexture.border.right = (int)(225f * Scale.x); //guiTexture.guiTexture.border.top = (int)(20f * Scale.y); //guiTexture.guiTexture.border.bottom = (int)(13f * Scale.y); //QamAcsess = Camera.main.GetComponent<camScript>(); MouseEvents.LEFTCLICK += MouseEvents_LEFTCLICK; MouseEvents.RIGHTCLICK += MouseEvents_RIGHTCLICK; MouseEvents.LEFTRELEASE += MouseEvents_LEFTRELEASE; UpdateManager.GUIUPDATE += UpdateManager_GUIUPDATE; }
void Start() { foreach (GameObject rectangle in GameObject.FindGameObjectsWithTag("Rectangles")) { //if (rectangle.gameObject.name == "FocusRectangle") //FocusSprite = rectangle.GetComponent<FocusRectangleObject>(); if (rectangle.gameObject.name == "SelectionRectangle") SelectionSprite = rectangle.GetComponent<SelectorScript>(); else if (rectangle.gameObject.name == "GroupRectangle") GroupSprite = rectangle.GetComponent<GroupRectangleScript>(); } MouseEvents.Setup(gameObject); SelectedGroup = ScriptableObject.CreateInstance<UnitGroup>(); SelectedGroup.startGroup(); //scrolling = (GetComponent<Scrolling>()) ? GetComponent<Scrolling>() : null; //if (camera.name == null) //{ camera = Camera.main; //} Scale = new Vector2((camera.pixelRect.width / gameObject.guiTexture.texture.width), (camera.pixelRect.height / gameObject.guiTexture.texture.height)); //gameObject.guiTexture.pixelInset = new Rect(0, -camera.pixelHeight, camera.pixelWidth, camera.pixelHeight); //if (gameObject.GetComponent<GUIText>() == null) gameObject.AddComponent<GUIText>(); gameObject.guiText.pixelOffset = new Vector2(-Camera.main.pixelWidth / 2 + 25 * Scale.x, Camera.main.pixelHeight/2 - 80 * Scale.y); MapViewArea = new Rect(20 * Scale.x, 20 * Scale.y, 1675 * Scale.x, 1047 * Scale.y); MainGuiArea = new Rect(1716 * Scale.x, 20 * Scale.y, 184 * Scale.x, 1047 * Scale.y); gameObject.guiText.fontSize = (int)(40f * Scale.x + 0.5f); //guiTexture.pixelInset = MapViewArea; //guiTexture.guiTexture.border.left = (int)(20f * Scale.x); //guiTexture.guiTexture.border.right = (int)(225f * Scale.x); //guiTexture.guiTexture.border.top = (int)(20f * Scale.y); //guiTexture.guiTexture.border.bottom = (int)(13f * Scale.y); //QamAcsess = Camera.main.GetComponent<camScript>(); MouseEvents.LEFTCLICK += MouseEvents_LEFTCLICK; MouseEvents.RIGHTCLICK += MouseEvents_RIGHTCLICK; MouseEvents.LEFTRELEASE += MouseEvents_LEFTRELEASE; UpdateManager.GUIUPDATE += UpdateManager_GUIUPDATE; }