本文整理汇总了C#中UIRect类的典型用法代码示例。如果您正苦于以下问题:C# UIRect类的具体用法?C# UIRect怎么用?C# UIRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIRect类属于命名空间,在下文中一共展示了UIRect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:upsky,项目名称:domru,代码行数:30,代码来源:GuiScreenTutorialLogoIconFix.cs
示例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;
}
开发者ID:alleeclark,项目名称:Vuforia,代码行数:15,代码来源:UICheckButton.cs
示例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);
}
开发者ID:upsky,项目名称:domru,代码行数:10,代码来源:GuiScreenDownBackFix.cs
示例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);
}
开发者ID:upsky,项目名称:domru,代码行数:11,代码来源:HandControllerForTutorial2.cs
示例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>();
}
}
开发者ID:GameSparksLtd,项目名称:GameSparks-Tappy,代码行数:12,代码来源:TweenAlpha.cs
示例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();
}
开发者ID:upsky,项目名称:domru,代码行数:17,代码来源:GuiScreenRecordLineFix.cs
示例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;
}
开发者ID:alleeclark,项目名称:Vuforia,代码行数:29,代码来源:UIRadioButton.cs
示例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;
}
开发者ID:alleeclark,项目名称:Vuforia,代码行数:10,代码来源:UILabel.cs
示例9: Awake
void Awake () { mRect = GetComponent<UIRect>(); }
开发者ID:jixiang111,项目名称:TTUI-Framework,代码行数:1,代码来源:TweenPosition.cs
示例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]);
}
开发者ID:hcutler,项目名称:24hoursofgood,代码行数:9,代码来源:UIPanel.cs
示例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;
}
}
开发者ID:floatyears,项目名称:Decrypt,代码行数:18,代码来源:UIRect.cs
示例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();
}
开发者ID:hyrio,项目名称:engineering-blog-examples,代码行数:17,代码来源:ViewPresenter.cs
示例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();
}
开发者ID:fengqk,项目名称:Art,代码行数:44,代码来源:NGUIMath.cs
示例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;
}
}
开发者ID:zhang00lei,项目名称:2048,代码行数:17,代码来源:UIRect.cs
示例15: Awake
private void Awake()
{
this.mRect = base.GetComponent<UIRect>();
}
开发者ID:floatyears,项目名称:Decrypt,代码行数:4,代码来源:TweenPosition.cs
示例16: FindCameraFor
private void FindCameraFor(UIRect.AnchorPoint ap)
{
if (ap.target == null || ap.rect != null)
{
ap.targetCam = null;
}
else
{
ap.targetCam = NGUITools.FindCameraForLayer(ap.target.gameObject.layer);
}
}
开发者ID:floatyears,项目名称:Decrypt,代码行数:11,代码来源:UIRect.cs
示例17: GetLocalPos
protected Vector3 GetLocalPos(UIRect.AnchorPoint ac, Transform trans)
{
if (this.anchorCamera == null || ac.targetCam == null)
{
return this.cachedTransform.localPosition;
}
Rect rect = ac.targetCam.rect;
Vector3 vector = ac.targetCam.WorldToViewportPoint(ac.target.position);
Vector3 vector2 = new Vector3(vector.x * rect.width + rect.x, vector.y * rect.height + rect.y, vector.z);
vector2 = this.mCam.ViewportToWorldPoint(vector2);
if (trans != null)
{
vector2 = trans.InverseTransformPoint(vector2);
}
vector2.x = Mathf.Floor(vector2.x + 0.5f);
vector2.y = Mathf.Floor(vector2.y + 0.5f);
return vector2;
}
开发者ID:floatyears,项目名称:Decrypt,代码行数:18,代码来源:UIRect.cs
示例18: MoveWidget
public static void MoveWidget(UIRect w, float x, float y)
{
NGUIMath.MoveRect(w, x, y);
}
开发者ID:floatyears,项目名称:Decrypt,代码行数:4,代码来源:NGUIMath.cs
示例19: DrawAnchorHandle
/// <summary>
/// Draw the specified anchor point.
/// </summary>
static public void DrawAnchorHandle (UIRect.AnchorPoint anchor, Transform myTrans, Vector3[] myCorners, int side, int id)
{
if (!anchor.target) return;
int i0, i1;
if (side == 0)
{
// Left
i0 = 0;
i1 = 1;
}
else if (side == 1)
{
// Top
i0 = 1;
i1 = 2;
}
else if (side == 2)
{
// Right
i0 = 3;
i1 = 2;
}
else
{
// Bottom
i0 = 0;
i1 = 3;
}
Vector3 myPos = (myCorners[i0] + myCorners[i1]) * 0.5f;
Vector3[] sides = null;
if (anchor.rect != null)
{
sides = anchor.rect.worldCorners;
}
else if (anchor.target.GetComponent<Camera>() != null)
{
sides = anchor.target.GetComponent<Camera>().GetWorldCorners();
}
Vector3 theirPos;
if (sides != null)
{
Vector3 v0, v1;
if (side == 0 || side == 2)
{
// Left or right
v0 = Vector3.Lerp(sides[0], sides[3], anchor.relative);
v1 = Vector3.Lerp(sides[1], sides[2], anchor.relative);
}
else
{
// Top or bottom
v0 = Vector3.Lerp(sides[0], sides[1], anchor.relative);
v1 = Vector3.Lerp(sides[3], sides[2], anchor.relative);
}
theirPos = HandleUtility.ProjectPointLine(myPos, v0, v1);
}
else
{
theirPos = anchor.target.position;
}
NGUIHandles.DrawShadowedLine(myCorners, myPos, theirPos, Color.yellow);
if (Event.current.GetTypeForControl(id) == EventType.Repaint)
{
Vector2 screenPoint = HandleUtility.WorldToGUIPoint(theirPos);
Rect rect = new Rect(screenPoint.x - 7f, screenPoint.y - 7f, 14f, 14f);
if (mYellowDot == null) mYellowDot = "sv_label_4";
Vector3 v0 = HandleUtility.WorldToGUIPoint(myPos);
Vector3 v1 = HandleUtility.WorldToGUIPoint(theirPos);
Handles.BeginGUI();
mYellowDot.Draw(rect, GUIContent.none, id);
Vector3 diff = v1 - v0;
bool isHorizontal = Mathf.Abs(diff.x) > Mathf.Abs(diff.y);
float mag = diff.magnitude;
if ((isHorizontal && mag > 60f) || (!isHorizontal && mag > 30f))
{
Vector3 pos = (myPos + theirPos) * 0.5f;
string text = anchor.absolute.ToString();
GUI.color = Color.yellow;
if (side == 0)
//.........这里部分代码省略.........
开发者ID:qd9218,项目名称:Spine2D-ARPG,代码行数:101,代码来源:UIWidgetInspector.cs
示例20: Awake
void Awake () {
mRect = GetComponent<UIRect>();
orignFrom = from;
orignTo = to;
}
开发者ID:fengqk,项目名称:Art,代码行数:5,代码来源:TweenPosition.cs
注:本文中的UIRect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论