void SetBounds(CarbonState state) { if (this.carbonState == CarbonState.ATMOSPHERIC) { carbonBoundRT = skyPanel.GetComponent <RectTransform>(); workingPanel = skyPanel; } if (this.carbonState == CarbonState.UNDERGROUND) { carbonBoundRT = groundPanel.GetComponent <RectTransform>(); workingPanel = groundPanel; } boundMin.x = workingPanel.transform.position.x - carbonBoundRT.rect.width / 2; boundMin.y = workingPanel.transform.position.y - carbonBoundRT.rect.height / 2; boundMax.x = workingPanel.transform.position.x + carbonBoundRT.rect.width / 2; boundMax.y = workingPanel.transform.position.y + carbonBoundRT.rect.height / 2; }
void SetState(CarbonState state) { this.carbonState = state; SetBounds(state); }
void SetBounds(CarbonState state) { if (this.carbonState == CarbonState.ATMOSPHERIC){ carbonBoundRT = skyPanel.GetComponent<RectTransform>(); workingPanel = skyPanel; } if (this.carbonState == CarbonState.UNDERGROUND){ carbonBoundRT = groundPanel.GetComponent<RectTransform>(); workingPanel = groundPanel; } boundMin.x = workingPanel.transform.position.x - carbonBoundRT.rect.width/2; boundMin.y = workingPanel.transform.position.y - carbonBoundRT.rect.height/2; boundMax.x = workingPanel.transform.position.x + carbonBoundRT.rect.width/2; boundMax.y = workingPanel.transform.position.y + carbonBoundRT.rect.height/2; }
//because the canvas is working in world space with an absolute width and height //I'll have to change things around. public void Initialize(Vector2 startingLocation, CarbonState state) { this.originalLocation = startingLocation; this.carbonState = state; print("original Location: " + originalLocation); }