/// <summary> /// Draws current element and all children. /// </summary> /// <param name="drawRect"> /// Parent region with <see cref="Rect"/> type. Already scaled. /// </param> /// <param name="active"> /// Flag for element if it is active of <see cref="System.Boolean"/> type. /// </param> public virtual void Draw(blindGUILayout parentLayout, bool active) { //Debug.Log(this.name+" parent layout: "+parentLayout.ToString()); blindGUILayout currentLayout; Rect containerRectangle = SetupLayout(parentLayout, out currentLayout); if (this.GetType() == typeof(blindGUIParentElement)) { GUI.Box(containerRectangle, this.name); } foreach (blindGUIParentElement element in m_elements) { element.Draw(currentLayout, m_enabled & active); } if (m_clipAssigned) { GUI.EndGroup(); m_clipAssigned = false; } if (m_colorChanged) { GUI.color = m_originalGUIColor; m_colorChanged = false; } }
/// <summary> /// Draws current element and all children. /// </summary> /// <param name="drawRect"> /// Parent region with <see cref="Rect"/> type. Already scaled. /// </param> /// <param name="active"> /// Flag for element if it is active of <see cref="System.Boolean"/> type. /// </param> public override void Draw( blindGUILayout parentLayout, bool active ) { CreateTiledColorTexture(); m_backgroundTexture = onePixelTexture; m_textureScaleMode = ScaleMode.StretchToFill; base.Draw( parentLayout, active ); }
/// <summary> /// Creates window for layer /// </summary> /// <param name="drawRect"> /// Parent region with <see cref="Rect"/> type. Already scaled. /// </param> /// <param name="parentScale"> /// Scale of parent element. Controller send here main scale /// </param> /// <param name="active"> /// Flag for element if it is active of <see cref="System.Boolean"/> type. /// </param> public override void Draw(blindGUILayout parentLayout, bool active) { if (m_alpha <= 0.25f) { return; } // Get frame of layer m_screenLayout = parentLayout; m_anchorPoint = new Vector2(0, 0); m_offset = new Vector2(0, 0); m_size = parentLayout.size; // Store gui color Color guiColor = GUI.color; // Set alpha GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, m_alpha); base.Draw(m_screenLayout, (m_alpha >= 0.75f)); // Restore gui color GUI.color = guiColor; }
/// <summary> /// Draws current element and all children. /// </summary> /// <param name="drawRect"> /// Parent region with <see cref="Rect"/> type. Already scaled. /// </param> /// <param name="active"> /// Flag for element if it is active of <see cref="System.Boolean"/> type. /// </param> public override void Draw(blindGUILayout parentLayout, bool active) { CreateTiledColorTexture(); m_backgroundTexture = onePixelTexture; m_textureScaleMode = ScaleMode.StretchToFill; base.Draw(parentLayout, active); }
public override void Draw(blindGUILayout parentLayout, bool active) { Rect elementFrame = GetFrame(parentLayout); m_style.font = m_font; m_style.fontStyle = m_fontStyle; m_style.normal.textColor = m_fontColor; m_style.alignment = m_textAnchor; m_text = GUI.PasswordField(elementFrame,m_text,m_passwordChar,m_maxLength,m_style); Debug.Log(m_text); base.Draw (parentLayout, active); }
public override void Draw(blindGUILayout parentLayout, bool active) { if (m_font == null) m_font = new Font(); Rect elementFrame = GetFrame(parentLayout); m_style.font = m_font; m_style.normal.textColor = m_fontColor; m_style.alignment = m_textAnchor; GUI.Label(elementFrame,m_text,m_style); base.Draw (parentLayout, active); }
public override void Draw(blindGUILayout parentLayout, bool active) { Rect elementFrame = GetFrame(parentLayout); m_style.font = m_font; m_style.fontStyle = m_fontStyle; m_style.normal.textColor = m_fontColor; m_style.alignment = m_textAnchor; m_text = GUI.PasswordField(elementFrame, m_text, m_passwordChar, m_maxLength, m_style); Debug.Log(m_text); base.Draw(parentLayout, active); }
public override void Draw( blindGUILayout parentLayout, bool active ) { // If autosize flag is true, resize button based on idle texture if (m_autoSizeToTexture) { if (m_backgroundTexture != null) { m_size.x = m_backgroundTexture.width; m_size.y = m_backgroundTexture.height; } } Rect containerFrame = GetFrame(parentLayout); if (m_backgroundTexture) { GUI.DrawTexture(containerFrame,m_backgroundTexture,m_textureScaleMode); } base.Draw(parentLayout, active); }
public override void Draw(blindGUILayout parentLayout, bool active) { if (m_font == null) m_font = new Font(); Rect elementFrame = GetFrame(parentLayout); m_style.font = m_font; m_style.fontStyle = m_fontStyle; m_style.normal.textColor = m_fontColor; m_style.alignment = m_textAnchor; m_text = GUI.TextArea(elementFrame,m_text,m_maxLength,m_style); Debug.Log(m_text); base.Draw (parentLayout, active); }
public override void Draw(blindGUILayout parentLayout, bool active) { if (m_font == null) { m_font = new Font(); } Rect elementFrame = GetFrame(parentLayout); m_style.font = m_font; m_style.normal.textColor = m_fontColor; m_style.alignment = m_textAnchor; GUI.Label(elementFrame, m_text, m_style); base.Draw(parentLayout, active); }
public override void Draw(blindGUILayout parentLayout, bool active) { // If autosize flag is true, resize button based on idle texture if (m_autoSizeToTexture) { if (m_backgroundTexture != null) { m_size.x = m_backgroundTexture.width; m_size.y = m_backgroundTexture.height; } } Rect containerFrame = GetFrame(parentLayout); if (m_backgroundTexture) { GUI.DrawTexture(containerFrame, m_backgroundTexture, m_textureScaleMode); } base.Draw(parentLayout, active); }
public override void Draw(blindGUILayout parentLayout, bool active) { if (m_font == null) { m_font = new Font(); } Rect elementFrame = GetFrame(parentLayout); m_style.font = m_font; m_style.fontStyle = m_fontStyle; m_style.normal.textColor = m_fontColor; m_style.alignment = m_textAnchor; m_text = GUI.TextField(elementFrame, m_text, m_maxLength, m_style); Debug.Log(m_text); base.Draw(parentLayout, active); }
/// <summary> /// Draws current element and all children. /// </summary> /// <param name="drawRect"> /// Parent region with <see cref="Rect"/> type. Already scaled. /// </param> /// <param name="active"> /// Flag for element if it is active of <see cref="System.Boolean"/> type. /// </param> public override void Draw(blindGUILayout parentLayout, bool active) { m_textureScaleMode = ScaleMode.ScaleAndCrop; Rect containerFrame = GetFrame(parentLayout); if ((containerFrame.width != 0) && (containerFrame.height != 0) && (m_backgroundTexture != null)) { if ((containerFrame.width != m_tiledTextureWidth) || (containerFrame.height != m_tiledTextureHeight)) { m_tiledTextureWidth = containerFrame.width; m_tiledTextureHeight = containerFrame.height; UpdateTexture(); } } base.Draw(parentLayout, active); }
/// <summary> /// Draws current element and all children. /// </summary> /// <param name="drawRect"> /// Parent region with <see cref="Rect"/> type. Already scaled. /// </param> /// <param name="active"> /// Flag for element if it is active of <see cref="System.Boolean"/> type. /// </param> public override void Draw( blindGUILayout parentLayout, bool active ) { m_textureScaleMode = ScaleMode.ScaleAndCrop; Rect containerFrame = GetFrame(parentLayout); if ((containerFrame.width != 0) && (containerFrame.height != 0) && (m_backgroundTexture != null)) { if ((containerFrame.width != m_tiledTextureWidth) || (containerFrame.height != m_tiledTextureHeight)) { m_tiledTextureWidth = containerFrame.width; m_tiledTextureHeight = containerFrame.height; UpdateTexture(); } } base.Draw(parentLayout, active); }
/// <summary> /// Creates window for layer /// </summary> /// <param name="drawRect"> /// Parent region with <see cref="Rect"/> type. Already scaled. /// </param> /// <param name="parentScale"> /// Scale of parent element. Controller send here main scale /// </param> /// <param name="active"> /// Flag for element if it is active of <see cref="System.Boolean"/> type. /// </param> public override void Draw( blindGUILayout parentLayout, bool active ) { if (m_alpha <= 0.25f) return; // Get frame of layer m_screenLayout = parentLayout; m_anchorPoint = new Vector2(0,0); m_offset = new Vector2(0,0); m_size = parentLayout.size; // Store gui color Color guiColor = GUI.color; // Set alpha GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, m_alpha); base.Draw( m_screenLayout , (m_alpha >= 0.75f) ); // Restore gui color GUI.color = guiColor; }
public override void Draw(blindGUILayout parentLayout, bool active) { // If autosize flag is true, resize button based on idle texture if (m_autoSizeToTexture) { if (m_idleImage != null) { m_size.x = m_idleImage.width; m_size.y = m_idleImage.height; } } SetButtonGraphics(active & m_enabled); Rect buttonFrame = GetFrame(parentLayout); if (m_enabled && active) { // Toggle button if (m_buttonType == blindGUIButton.BUTTON_TYPE.ToggleButton) { m_pushed = GUI.Toggle(buttonFrame, m_pushed, "", m_style); if (m_pushed) { m_buttonState = blindGUIButton.BUTTON_STATE.Pressed; } else { m_buttonState = blindGUIButton.BUTTON_STATE.Idle; } if ((m_prevPushState != m_pushed) && (m_buttonStateChangedDelegate != null)) { m_buttonStateChangedDelegate(this, m_pushed); } m_prevPushState = m_pushed; // Radio Button } else if (m_buttonType == blindGUIButton.BUTTON_TYPE.RadioButton) { bool m_stateBeforePush = m_pushed; m_pushed = GUI.Toggle(buttonFrame, m_pushed, "", m_style); if (m_stateBeforePush && !m_pushed) { m_pushed = true; } if (!m_stateBeforePush && m_pushed) { m_buttonState = blindGUIButton.BUTTON_STATE.Pressed; foreach (blindGUIButton button in m_radiobuttonsInGroup) { button.m_pushed = false; if (button.m_buttonStateChangedDelegate != null) { button.m_buttonStateChangedDelegate(button, false); } } if (m_buttonStateChangedDelegate != null) { m_buttonStateChangedDelegate(this, m_pushed); } } if (m_pushed) { m_buttonState = blindGUIButton.BUTTON_STATE.Pressed; } else { m_buttonState = blindGUIButton.BUTTON_STATE.Idle; } //m_prevPushState = m_pushed; // Repeat Button } else if (m_buttonType == blindGUIButton.BUTTON_TYPE.RepeatButton) { m_buttonState = blindGUIButton.BUTTON_STATE.Idle; bool buttonResult = GUI.RepeatButton(buttonFrame, "", m_style); if (buttonResult && (m_buttonClickDelegate != null)) { m_buttonClickDelegate(this); } // Default click button } else { m_buttonState = blindGUIButton.BUTTON_STATE.Idle; bool buttonResult = GUI.Button(buttonFrame, "", m_style); if (buttonResult && (m_buttonClickDelegate != null)) { m_buttonClickDelegate(this); } } } else { GUI.Button(buttonFrame, "", m_style); } base.Draw(parentLayout, active & m_enabled); }
/// <summary> /// Sets rotation, scale and arranges current element /// </summary> /// <param name="parentLayout"> /// Layout of parent element of <see cref="blindGUILayout"/> type /// </param> /// <param name="elementConfig"> /// Current element configuration of <see cref="blindGUIElementConfig"/> type /// </param> /// <param name="currentLayout"> /// Current element layout for hierarhy. <see cref="blindGUILayout"/> type /// </param> /// <returns> /// Rectaingle of current element. <see cref="Rect"/> type. /// </returns> private Rect SetupLayout( blindGUILayout parentLayout, out blindGUILayout currentLayout ) { if (m_angle != 0) m_clipping = false; if (m_scale == 0) m_scale = 0.0001f; blindGUIElementConfig elementConfig = GetElement(parentLayout); //new blindGUIElementConfig( new Vector2(m_scale,m_scale), m_rotationAnchorPoint, m_offset, new Vector2( m_size.x, m_size.y), m_angle); if (!m_clipAssigned) { GUI.matrix = Matrix4x4.identity; } Vector2 realAnchorPoint = new Vector2( -elementConfig.size.x*(0.5f+elementConfig.anchorPoint.x), -elementConfig.size.y*(0.5f+elementConfig.anchorPoint.y) ); Vector2 currentAnchorPoint = new Vector2( parentLayout.realAnchorPoint.x + elementConfig.offset.x*parentLayout.scale.x*Mathf.Cos(-parentLayout.angle*Mathf.Deg2Rad) + elementConfig.offset.y*parentLayout.scale.y*Mathf.Sin(-parentLayout.angle*Mathf.Deg2Rad) , parentLayout.realAnchorPoint.y +elementConfig.offset.y*parentLayout.scale.y*Mathf.Cos(-parentLayout.angle*Mathf.Deg2Rad) - elementConfig.offset.x*parentLayout.scale.x*Mathf.Sin(-parentLayout.angle*Mathf.Deg2Rad)); acnhorPointOnScreen = currentAnchorPoint+realAnchorPoint; // Current element scale Vector2 currentScale = new Vector2(parentLayout.scale.x*elementConfig.scale.x, parentLayout.scale.y*elementConfig.scale.y); // Current element angle float currentAngle = parentLayout.angle+elementConfig.angle; if (!m_clipAssigned) { GUIUtility.ScaleAroundPivot(currentScale, currentAnchorPoint); GUIUtility.RotateAroundPivot(currentAngle, currentAnchorPoint); } if (m_clipping) { currentLayout = new blindGUILayout( -realAnchorPoint, m_anchorPoint, currentScale, elementConfig.size, currentAngle ); } else { currentLayout = new blindGUILayout( currentAnchorPoint, m_anchorPoint, currentScale, elementConfig.size, currentAngle ); } Rect resultRect = new Rect( currentAnchorPoint.x+realAnchorPoint.x, currentAnchorPoint.y +realAnchorPoint.y, elementConfig.size.x, elementConfig.size.y); if (m_clipping) { Rect clipRect = new Rect(currentAnchorPoint.x+realAnchorPoint.x,currentAnchorPoint.y+realAnchorPoint.y, elementConfig.size.x+20, elementConfig.size.y+20); if (!m_clipAssigned) { GUI.BeginGroup( clipRect , "", new GUIStyle() ); m_clipAssigned = true; } resultRect = new Rect(0,0, elementConfig.size.x, elementConfig.size.y); } if (!m_colorChanged) { m_originalGUIColor = GUI.color; GUI.color = new Color( m_originalGUIColor.r, m_originalGUIColor.g, m_originalGUIColor.b, m_originalGUIColor.a * m_alpha ); m_colorChanged = true; } return resultRect; }
/// <summary> /// Draws current element and all children. /// </summary> /// <param name="drawRect"> /// Parent region with <see cref="Rect"/> type. Already scaled. /// </param> /// <param name="active"> /// Flag for element if it is active of <see cref="System.Boolean"/> type. /// </param> public virtual void Draw( blindGUILayout parentLayout, bool active) { //Debug.Log(this.name+" parent layout: "+parentLayout.ToString()); blindGUILayout currentLayout; Rect containerRectangle = SetupLayout( parentLayout, out currentLayout ); if (this.GetType() == typeof(blindGUIParentElement)) { GUI.Box(containerRectangle,this.name); } foreach( blindGUIParentElement element in m_elements) { element.Draw(currentLayout, m_enabled & active); } if (m_clipAssigned) { GUI.EndGroup(); m_clipAssigned = false; } if (m_colorChanged) { GUI.color = m_originalGUIColor; m_colorChanged = false; } }
public override void Draw( blindGUILayout parentLayout, bool active ) { // If autosize flag is true, resize button based on idle texture if (m_autoSizeToTexture) { if (m_idleImage != null) { m_size.x = m_idleImage.width; m_size.y = m_idleImage.height; } } SetButtonGraphics( active & m_enabled ); Rect buttonFrame = GetFrame(parentLayout); if (m_enabled && active) { // Toggle button if (m_buttonType == blindGUIButton.BUTTON_TYPE.ToggleButton) { m_pushed = GUI.Toggle(buttonFrame, m_pushed, "",m_style); if (m_pushed) { m_buttonState = blindGUIButton.BUTTON_STATE.Pressed; } else { m_buttonState = blindGUIButton.BUTTON_STATE.Idle; } if ((m_prevPushState != m_pushed) && (m_buttonStateChangedDelegate != null)) { m_buttonStateChangedDelegate(this, m_pushed); } m_prevPushState = m_pushed; // Radio Button } else if (m_buttonType == blindGUIButton.BUTTON_TYPE.RadioButton) { bool m_stateBeforePush = m_pushed; m_pushed = GUI.Toggle(buttonFrame, m_pushed, "",m_style); if (m_stateBeforePush && !m_pushed) { m_pushed = true; } if (!m_stateBeforePush && m_pushed) { m_buttonState = blindGUIButton.BUTTON_STATE.Pressed; foreach (blindGUIButton button in m_radiobuttonsInGroup) { button.m_pushed = false; if (button.m_buttonStateChangedDelegate != null) { button.m_buttonStateChangedDelegate( button, false); } } if (m_buttonStateChangedDelegate != null) { m_buttonStateChangedDelegate(this, m_pushed); } } if (m_pushed) { m_buttonState = blindGUIButton.BUTTON_STATE.Pressed; } else { m_buttonState = blindGUIButton.BUTTON_STATE.Idle; } //m_prevPushState = m_pushed; // Repeat Button } else if (m_buttonType == blindGUIButton.BUTTON_TYPE.RepeatButton) { m_buttonState = blindGUIButton.BUTTON_STATE.Idle; bool buttonResult = GUI.RepeatButton(buttonFrame, "", m_style); if (buttonResult && (m_buttonClickDelegate != null)) { m_buttonClickDelegate(this); } // Default click button } else { m_buttonState = blindGUIButton.BUTTON_STATE.Idle; bool buttonResult = GUI.Button(buttonFrame, "", m_style); if (buttonResult && (m_buttonClickDelegate != null)) { m_buttonClickDelegate(this); } } } else { GUI.Button(buttonFrame, "", m_style); } base.Draw(parentLayout, active & m_enabled); }
/// <summary> /// Returns frame for current element /// </summary> /// <param name="parentLayout"> /// Parent layout of <see cref="blindGUILayout"/> type. /// </param> /// <returns> /// Current elements's frame. <see cref="Rect"/> type; /// </returns> protected Rect GetFrame( blindGUILayout parentLayout ) { blindGUILayout temp; return SetupLayout( parentLayout, out temp ); }
/// <summary> /// Sets rotation, scale and arranges current element /// </summary> /// <param name="parentLayout"> /// Layout of parent element of <see cref="blindGUILayout"/> type /// </param> /// <param name="elementConfig"> /// Current element configuration of <see cref="blindGUIElementConfig"/> type /// </param> /// <param name="currentLayout"> /// Current element layout for hierarhy. <see cref="blindGUILayout"/> type /// </param> /// <returns> /// Rectaingle of current element. <see cref="Rect"/> type. /// </returns> private Rect SetupLayout(blindGUILayout parentLayout, out blindGUILayout currentLayout) { if (m_angle != 0) { m_clipping = false; } if (m_scale == 0) { m_scale = 0.0001f; } blindGUIElementConfig elementConfig = GetElement(parentLayout); //new blindGUIElementConfig( new Vector2(m_scale,m_scale), m_rotationAnchorPoint, m_offset, new Vector2( m_size.x, m_size.y), m_angle); if (!m_clipAssigned) { GUI.matrix = Matrix4x4.identity; } Vector2 realAnchorPoint = new Vector2(-elementConfig.size.x * (0.5f + elementConfig.anchorPoint.x), -elementConfig.size.y * (0.5f + elementConfig.anchorPoint.y)); Vector2 currentAnchorPoint = new Vector2(parentLayout.realAnchorPoint.x + elementConfig.offset.x * parentLayout.scale.x * Mathf.Cos(-parentLayout.angle * Mathf.Deg2Rad) + elementConfig.offset.y * parentLayout.scale.y * Mathf.Sin(-parentLayout.angle * Mathf.Deg2Rad) , parentLayout.realAnchorPoint.y + elementConfig.offset.y * parentLayout.scale.y * Mathf.Cos(-parentLayout.angle * Mathf.Deg2Rad) - elementConfig.offset.x * parentLayout.scale.x * Mathf.Sin(-parentLayout.angle * Mathf.Deg2Rad)); acnhorPointOnScreen = currentAnchorPoint + realAnchorPoint; // Current element scale Vector2 currentScale = new Vector2(parentLayout.scale.x * elementConfig.scale.x, parentLayout.scale.y * elementConfig.scale.y); // Current element angle float currentAngle = parentLayout.angle + elementConfig.angle; if (!m_clipAssigned) { GUIUtility.ScaleAroundPivot(currentScale, currentAnchorPoint); GUIUtility.RotateAroundPivot(currentAngle, currentAnchorPoint); } if (m_clipping) { currentLayout = new blindGUILayout(-realAnchorPoint, m_anchorPoint, currentScale, elementConfig.size, currentAngle); } else { currentLayout = new blindGUILayout(currentAnchorPoint, m_anchorPoint, currentScale, elementConfig.size, currentAngle); } Rect resultRect = new Rect(currentAnchorPoint.x + realAnchorPoint.x, currentAnchorPoint.y + realAnchorPoint.y, elementConfig.size.x, elementConfig.size.y); if (m_clipping) { Rect clipRect = new Rect(currentAnchorPoint.x + realAnchorPoint.x, currentAnchorPoint.y + realAnchorPoint.y, elementConfig.size.x + 20, elementConfig.size.y + 20); if (!m_clipAssigned) { GUI.BeginGroup(clipRect, "", new GUIStyle()); m_clipAssigned = true; } resultRect = new Rect(0, 0, elementConfig.size.x, elementConfig.size.y); } if (!m_colorChanged) { m_originalGUIColor = GUI.color; GUI.color = new Color(m_originalGUIColor.r, m_originalGUIColor.g, m_originalGUIColor.b, m_originalGUIColor.a * m_alpha); m_colorChanged = true; } return(resultRect); }
/// <summary> /// Returns current element configuration /// </summary> /// <param name="parentLayout"> /// Layout of parent element of <see cref="blindGUILayout"/> type /// </param> /// <returns> /// Returns configuration for this element of <see cref="blindGUIElementConfig"/> type. /// </returns> private blindGUIElementConfig GetElement(blindGUILayout parentLayout) { float _angle = m_angle; Vector2 _anchorPoint = m_anchorPoint; Vector2 _size = m_size; Vector2 _offset = m_offset; float _scale = m_scale; //------------------------------------------------- // Fix angle // Set parameters according to alignment if ((m_horizontalAlign != blindGUIParentElement.HALIGN.free) || (m_verticalAlign != blindGUIParentElement.VALIGN.free)) { _angle = 0; } //------------------------------------------------- // Fix anchor point // Horizontal if (m_horizontalAlign == blindGUIParentElement.HALIGN.left) { _anchorPoint.x = 0f; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.center) { _anchorPoint.x = 0; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.stretch) { _anchorPoint.x = 0; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.right) { _anchorPoint.x = 0f; } // Vertical if (m_verticalAlign == blindGUIParentElement.VALIGN.top) { _anchorPoint.y = 0f; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.center) { _anchorPoint.y = 0; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.stretch) { _anchorPoint.y = 0; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.bottom) { _anchorPoint.y = 0f; } //------------------------------------------------- // Fix size // Horizontal if (m_horizontalAlign == blindGUIParentElement.HALIGN.stretch) { _size.x = parentLayout.size.x / _scale; } // Vertical if (m_verticalAlign == blindGUIParentElement.VALIGN.stretch) { _size.y = parentLayout.size.y / _scale; } //------------------------------------------------- // Fix offset // Horizontal if (m_horizontalAlign == blindGUIParentElement.HALIGN.left) { _offset.x += -parentLayout.size.x * (0.5f + parentLayout.anchorPoint.x) + _size.x * 0.5f * _scale; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.center) { _offset.x += -parentLayout.size.x * (0.5f + parentLayout.anchorPoint.x - 0.5f); } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.right) { _offset.x = -parentLayout.size.x * (0.5f + parentLayout.anchorPoint.x - 1.0f) - _size.x * _scale * 0.5f - _offset.x; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.stretch) { _offset.x = -parentLayout.size.x * (0.5f + parentLayout.anchorPoint.x - 0.5f); } // Vertical if (m_verticalAlign == blindGUIParentElement.VALIGN.top) { _offset.y += -parentLayout.size.y * (0.5f + parentLayout.anchorPoint.y) + _size.y * 0.5f * _scale; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.center) { _offset.y += -parentLayout.size.y * (0.5f + parentLayout.anchorPoint.y - 0.5f); } else if (m_verticalAlign == blindGUIParentElement.VALIGN.bottom) { _offset.y = -parentLayout.size.y * (0.5f + parentLayout.anchorPoint.y - 1.0f) - _size.y * _scale * 0.5f - _offset.y; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.stretch) { _offset.y = -parentLayout.size.y * (0.5f + parentLayout.anchorPoint.y - 0.5f); } return(new blindGUIElementConfig(new Vector2(_scale, _scale), _anchorPoint, _offset, _size, _angle)); }
/// <summary> /// Returns frame for current element /// </summary> /// <param name="parentLayout"> /// Parent layout of <see cref="blindGUILayout"/> type. /// </param> /// <returns> /// Current elements's frame. <see cref="Rect"/> type; /// </returns> protected Rect GetFrame(blindGUILayout parentLayout) { blindGUILayout temp; return(SetupLayout(parentLayout, out temp)); }
/// <summary> /// Returns current element configuration /// </summary> /// <param name="parentLayout"> /// Layout of parent element of <see cref="blindGUILayout"/> type /// </param> /// <returns> /// Returns configuration for this element of <see cref="blindGUIElementConfig"/> type. /// </returns> private blindGUIElementConfig GetElement( blindGUILayout parentLayout ) { float _angle = m_angle; Vector2 _anchorPoint = m_anchorPoint; Vector2 _size = m_size; Vector2 _offset = m_offset; float _scale = m_scale; //------------------------------------------------- // Fix angle // Set parameters according to alignment if ((m_horizontalAlign != blindGUIParentElement.HALIGN.free) || (m_verticalAlign != blindGUIParentElement.VALIGN.free)) { _angle = 0; } //------------------------------------------------- // Fix anchor point // Horizontal if (m_horizontalAlign == blindGUIParentElement.HALIGN.left) { _anchorPoint.x = 0f; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.center) { _anchorPoint.x = 0; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.stretch) { _anchorPoint.x = 0; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.right) { _anchorPoint.x = 0f; } // Vertical if (m_verticalAlign == blindGUIParentElement.VALIGN.top) { _anchorPoint.y = 0f; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.center) { _anchorPoint.y = 0; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.stretch) { _anchorPoint.y = 0; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.bottom) { _anchorPoint.y = 0f; } //------------------------------------------------- // Fix size // Horizontal if (m_horizontalAlign == blindGUIParentElement.HALIGN.stretch) { _size.x = parentLayout.size.x / _scale; } // Vertical if (m_verticalAlign == blindGUIParentElement.VALIGN.stretch) { _size.y = parentLayout.size.y / _scale; } //------------------------------------------------- // Fix offset // Horizontal if (m_horizontalAlign == blindGUIParentElement.HALIGN.left) { _offset.x += -parentLayout.size.x*(0.5f+parentLayout.anchorPoint.x)+_size.x*0.5f*_scale; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.center) { _offset.x += -parentLayout.size.x*(0.5f+parentLayout.anchorPoint.x-0.5f); } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.right) { _offset.x = -parentLayout.size.x*(0.5f+parentLayout.anchorPoint.x-1.0f) - _size.x*_scale*0.5f - _offset.x; } else if (m_horizontalAlign == blindGUIParentElement.HALIGN.stretch) { _offset.x = -parentLayout.size.x*(0.5f+parentLayout.anchorPoint.x-0.5f); } // Vertical if (m_verticalAlign == blindGUIParentElement.VALIGN.top) { _offset.y += -parentLayout.size.y*(0.5f+parentLayout.anchorPoint.y)+_size.y*0.5f*_scale; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.center) { _offset.y += -parentLayout.size.y*(0.5f+parentLayout.anchorPoint.y-0.5f); } else if (m_verticalAlign == blindGUIParentElement.VALIGN.bottom) { _offset.y = -parentLayout.size.y*(0.5f+parentLayout.anchorPoint.y-1.0f) - _size.y*_scale*0.5f - _offset.y; } else if (m_verticalAlign == blindGUIParentElement.VALIGN.stretch) { _offset.y = -parentLayout.size.y*(0.5f+parentLayout.anchorPoint.y-0.5f); } return new blindGUIElementConfig( new Vector2(_scale,_scale), _anchorPoint, _offset, _size, _angle); }