本文整理汇总了C#中UIRect类的典型用法代码示例。如果您正苦于以下问题:C# UIRect类的具体用法?C# UIRect怎么用?C# UIRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIRect类属于命名空间,在下文中一共展示了UIRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
_uiItem = this.GetSafeComponent<UIRect>();
float w = Screen.width ;
float h = Screen.height;
float res = h/w;
//Debug.LogWarning(res);
if (res > 1.55) //16:10
{
_uiItem.leftAnchor.Set(0f, 32f);
_uiItem.rightAnchor.Set(0f, 284f);
_uiItem.bottomAnchor.Set(0.5f, -126f);
_uiItem.topAnchor.Set(0.5f, 126f);
}
//228
if (res > 1.45 && res < 1.55) //3:2
{
_uiItem.leftAnchor.Set(0f, 32f);
_uiItem.rightAnchor.Set(0f, 260f);
_uiItem.bottomAnchor.Set(0.5f, -114f);
_uiItem.topAnchor.Set(0.5f, 114f);
}
//не нужно
//if (res < 1.45) //4:3
}
示例2: UICheckButton
/// <summary>
/// Constructs a UIElement with selected and unselected states
/// param rect[] takes an array of UIRect dimentions for drawing of all options
/// param path[] takes an array of path names to load appropriate assets from Resources
/// param selected specifies whether the element is in selected or unselected state
/// </param>
public UICheckButton(UIRect rect, bool selected, string[] path)
{
this.mRect = rect;
mSelected = selected;
mStyle = new GUIStyle();
mStyle.normal.background = Resources.Load(path[0]) as Texture2D;
mStyle.active.background = Resources.Load(path[1]) as Texture2D;
mStyle.onNormal.background = Resources.Load(path[1]) as Texture2D;
}
示例3: SetToTarget
private void SetToTarget()
{
var uiCamera = transform.root.GetComponentInChildren<Camera>();
_uiItem = this.GetSafeComponent<UIRect>();
Vector3 offset = new Vector3(0, _yOffset, 0);
Vector3 pos = uiCamera.ScreenToWorldPoint(Camera.main.WorldToScreenPoint(_bottomMarker.position + offset));
_uiItem.transform.position = pos;
_uiItem.transform.SetLocalZ(0);
}
示例4: Start
private void Start()
{
_uiItem = this.GetSafeComponent<UIRect>();
_uiItem.enabled = false;
EventMessenger.Subscribe(GameEvent.OnTutorialCompleteShowText, this, () => Invoke("ShowSprite", _clickInterval));
EventMessenger.Subscribe(GameEvent.OnTutorial_ClickByTarget, this, () => Invoke("MoveToButtonStart", 0f));
Invoke("SetStartPos", 2f);
}
示例5: Cache
void Cache ()
{
mCached = true;
mRect = GetComponent<UIRect>();
if (mRect == null)
{
Renderer ren = GetComponent<Renderer>();
if (ren != null) mMat = ren.material;
if (mMat == null) mRect = GetComponentInChildren<UIRect>();
}
}
示例6: Start
void Start ()
{
_uiItem = this.GetSafeComponent<UIRect>();
//float w = Screen.width ;
//float h = Screen.height;
//float res = h/w;
//Debug.LogWarning(res);
_uiItem.leftAnchor.target = _uiItem.rightAnchor.target = transform.root.Find("Panel1");
_uiItem.leftAnchor.Set(0f, 0f);
_uiItem.rightAnchor.Set(1f, 0f);
_uiItem.ResetAnchors();
}
示例7: UIRadioButton
/// <summary>
/// Constructs a UIElement with series of options to choose from;
/// Only one option is selected at a time. param index specifies which option is set to true
/// param rect[] takes an array of UIRect dimentions for drawing of all options
/// param path[,] takes an array of path names to load appropriate assets from Resources
/// </param>
public UIRadioButton(UIRect[] rect, int index, string[,] path)
{
if(index > rect.Length)
{
return;
}
this.mRect = rect;
mStyle = new GUIStyle[rect.Length];
for(int i = 0; i < mStyle.Length; i++)
{
mStyle[i] = new GUIStyle();
mStyle[i].normal.background = Resources.Load(path[i,0]) as Texture2D;
mStyle[i].active.background = Resources.Load(path[i,1]) as Texture2D;
mStyle[i].onNormal.background = Resources.Load(path[i,1]) as Texture2D;
}
mOptionsTapped = new bool[rect.Length];
mOptionsSelected = new bool[rect.Length];
mOptionsSelected[index] = true;
}
示例8: UILabel
/// <summary>
/// Initializes a new instance for label
/// <param name='rect'> specifies label size
/// <param name='path'> specifies path for assets to load from Resources
public UILabel(UIRect rect, string path)
{
this.mRect = rect;
mStyle = new GUIStyle();
mStyle.normal.background = Resources.Load(path) as Texture2D;
}
示例9: Awake
void Awake () { mRect = GetComponent<UIRect>(); }
示例10: IsVisible
/// <summary>
/// Returns whether the specified widget is visible by the panel.
/// </summary>
public bool IsVisible (UIRect w)
{
Vector3[] corners = w.worldCorners;
return IsVisible(corners[0], corners[1], corners[2], corners[3]);
}
示例11: ParentHasChanged
public virtual void ParentHasChanged()
{
this.mParentFound = false;
UIRect y = NGUITools.FindInParents<UIRect>(this.cachedTransform.parent);
if (this.mParent != y)
{
if (this.mParent)
{
this.mParent.mChildren.Remove(this);
}
this.mParent = y;
if (this.mParent)
{
this.mParent.mChildren.Add(this);
}
this.mRootSet = false;
}
}
示例12: Awake
void Awake()
{
// This will allow to set the view in the inspector if we want to
ViewRoot = ViewRoot ?? GetComponent<UIRect>();
// Set the alpha to cero so the item is created
// invisible. When the show method is called
// the view will be made visible using a transition.
#if UNITY_EDITOR
if (UnityEditor.EditorApplication.isPlaying)
UpdateAlpha(0);
#else
ViewRoot.alpha = 0f;
#endif
AwakeUnityMsg();
}
示例13: MoveRect
/// <summary>
/// Adjust the rectangle's position using the specified local delta coordinates.
/// </summary>
static public void MoveRect (UIRect rect, float x, float y)
{
int ix = Mathf.FloorToInt(x + 0.5f);
int iy = Mathf.FloorToInt(y + 0.5f);
Transform t = rect.cachedTransform;
t.localPosition += new Vector3(ix, iy);
int anchorCount = 0;
if (rect.leftAnchor.target)
{
++anchorCount;
rect.leftAnchor.absolute += ix;
}
if (rect.rightAnchor.target)
{
++anchorCount;
rect.rightAnchor.absolute += ix;
}
if (rect.bottomAnchor.target)
{
++anchorCount;
rect.bottomAnchor.absolute += iy;
}
if (rect.topAnchor.target)
{
++anchorCount;
rect.topAnchor.absolute += iy;
}
#if UNITY_EDITOR
NGUITools.SetDirty(rect);
#endif
// If all sides were anchored, we're done
if (anchorCount != 0) rect.UpdateAnchors();
}
示例14: ParentHasChanged
/// <summary>
/// Call this function when the rectangle's parent has changed.
/// </summary>
public virtual void ParentHasChanged ()
{
mParentFound = false;
UIRect pt = NGUITools.FindInParents<UIRect>(cachedTransform.parent);
if (mParent != pt)
{
if (mParent) mParent.mChildren.Remove(this);
mParent = pt;
if (mParent) mParent.mChildren.Add(this);
mRootSet = false;
}
}
示例15: Awake
private void Awake()
{
this.mRect = base.GetComponent<UIRect>();
}