public void updateForGUI() { // reset the cache since maybe the sice in GUI will be used ahead casheSizeInGUI.x = -1f; // locate GUI element according new screen size (or whatever event fire this method) GUIScreenLayoutManager.locateForGUI(transform, getSizeInPixels()); }
public void updateForGUI() { // if using offset as proportion then convert it as pixels if (!xAsPixels) { offsetInPixels.x = offset.x * Screen.width; } else { offsetInPixels.x = offset.x; } // if using offset as propportion then convert it as pixels if (!yAsPixels) { offsetInPixels.y = offset.y * Screen.height; } else { offsetInPixels.y = offset.y; } // then apply position correction GUIScreenLayoutManager.adjustPos(transform, guiElem, offsetInPixels, layout); }
private void locateInScreen() { Vector2 sizeInPixels; sizeInPixels.x = sizeFactor.x * Screen.width; sizeInPixels.y = sizeFactor.y * Screen.height; GUIScreenLayoutManager.locateForGUI(transform, sizeInPixels); }
public Rect getScreenBoundsAA() { // checks if the cached size has changed if (_screenBounds.x == -1f) { _screenBounds = GUIScreenLayoutManager.getPositionInScreen(guiElem); } return(_screenBounds); }
public Rect getScreenBoundsAA() { if (_screenBounds.x == -1f) { // here I suppose this game object has attached a GUICustomElement _screenBounds = GUIScreenLayoutManager.positionInScreen(GetComponent <GUICustomElement>()); } return(_screenBounds); }
/// <summary> /// Gets the size in GUI space. /// </summary> /// <returns> /// The size in GUI space /// </returns> public Vector2 getSizeInGUI() { // if size was not calculated yet then proceed and cache it if (casheSizeInGUI.x == -1f) { Vector2 sizeInPixels = getSizeInPixels(); casheSizeInGUI = GUIScreenLayoutManager.sizeInGUI(sizeInPixels); } return(casheSizeInGUI); }
public Rect getScreenBoundsAA() { // This method called only once if the gameobject is a non destroyable game object // if used with a Unity's GUITexture if (guiTexture != null) { return(guiTexture.GetScreenRect(Camera.main)); } // here I suppose this game object has attached a GUICustomElement else { return(GUIScreenLayoutManager.positionInScreen(GetComponent <GUICustomElement>())); } }
void OnDestroy() { for (int i = 0, c = listeners.Length; i < c; ++i) { listeners[i] = null; } listeners = null; // this is to avoid nullifying or destroying static variables. Instance variables can be destroyed before this check if (duplicated) { duplicated = false; // reset the flag for next time return; } instance = null; }
public void updateForGUI() { // if using offset as percentage then convert it as pixels if (asProportion) { offsetCalculation.x = offset.x * Screen.width; offsetCalculation.y = offset.y * Screen.height; } else { offsetCalculation.x = offset.x; offsetCalculation.y = offset.y; } // then apply position correction GUIScreenLayoutManager.adjustPos(transform, guiElem, offsetCalculation, layout); }
void Awake() { if (instance != null && instance != this) { duplicated = true; #if UNITY_EDITOR DestroyImmediate(this.gameObject); #else Destroy(this.gameObject); #endif } else { instance = this; DontDestroyOnLoad(gameObject); initialize(); } }
public void updateForGUI() { GUIScreenLayoutManager.locateForGUI(transform, getSizeInPixels()); }
/// <summary> /// Gets the size in GUI space. /// </summary> /// <returns> /// The size in GUI space /// </returns> public Vector2 getSizeInGUI() { return(GUIScreenLayoutManager.sizeInGUI(getSizeInPixels())); }