本文整理汇总了C#中UnityEngine.RectTransform类的典型用法代码示例。如果您正苦于以下问题:C# RectTransform类的具体用法?C# RectTransform怎么用?C# RectTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RectTransform类属于UnityEngine命名空间,在下文中一共展示了RectTransform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake()
{
_resizedPanel = (ResizeParent ? transform.parent : transform) as RectTransform;
var maximalSizeMargin = 10;
_maximalSize = new Vector2(Screen.width - maximalSizeMargin, Screen.height - maximalSizeMargin);
}
开发者ID:Youenn-Bouglouan,项目名称:Water,代码行数:7,代码来源:Resizer.cs
示例2: State
public State(RectTransform rect) {
this.anchorMin = rect.anchorMin;
this.anchorMax = rect.anchorMax;
this.to = rect.anchoredPosition;
}
开发者ID:RuFengLau,项目名称:Unity3d.UI.Windows,代码行数:7,代码来源:WindowAnimationTransitionSlide.cs
示例3: Start
// Use this for initialization
void Start()
{
timescaleButtonImage = GameObject.Find("Timescale Button").GetComponent<Image>();
buttonTargetColor = Color.white;
timescaleInfoTransform = transform.GetComponent<RectTransform>();
hiddenPos = timescaleInfoTransform.position;
visiblePos = timescaleInfoTransform.position + new Vector3(340,0,0);
timescaleInfoTransform.position = hiddenPos;
activeColor = Color.white;
inactiveColor = new Color(1,1,1,0.1f);
nextUpgradeColorVisible = new Color(0,1,0,1);
nextUpgradeColorTransparent = new Color(0,1,0,0.05f);
timescaleImages = new RawImage[9];
timescaleImages[0] = transform.Find("Current Timescale").Find("Timescale Bar").Find("1").GetComponent<RawImage>();
timescaleImages[1] = transform.Find("Current Timescale").Find("Timescale Bar").Find("2").GetComponent<RawImage>();
timescaleImages[2] = transform.Find("Current Timescale").Find("Timescale Bar").Find("3").GetComponent<RawImage>();
timescaleImages[3] = transform.Find("Current Timescale").Find("Timescale Bar").Find("4").GetComponent<RawImage>();
timescaleImages[4] = transform.Find("Current Timescale").Find("Timescale Bar").Find("5").GetComponent<RawImage>();
timescaleImages[5] = transform.Find("Current Timescale").Find("Timescale Bar").Find("6").GetComponent<RawImage>();
timescaleImages[6] = transform.Find("Current Timescale").Find("Timescale Bar").Find("7").GetComponent<RawImage>();
timescaleImages[7] = transform.Find("Current Timescale").Find("Timescale Bar").Find("8").GetComponent<RawImage>();
timescaleImages[8] = transform.Find("Current Timescale").Find("Timescale Bar").Find("9").GetComponent<RawImage>();
ClearTimescale();
}
开发者ID:redahanb,项目名称:Spectral,代码行数:30,代码来源:UpgradeReactionTime.cs
示例4: CalculateAnchorSnapValues
internal static void CalculateAnchorSnapValues(Transform parentSpace, Transform self, RectTransform gui, int minmaxX, int minmaxY)
{
for (int mainAxis = 0; mainAxis < 2; ++mainAxis)
{
RectTransformSnapping.s_SnapGuides[mainAxis].Clear();
parentSpace.GetComponent<RectTransform>().GetWorldCorners(RectTransformSnapping.s_Corners);
for (int index = 0; index < RectTransformSnapping.kSidesAndMiddle.Length; ++index)
{
float alongMainAxis = RectTransformSnapping.kSidesAndMiddle[index];
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(alongMainAxis, new Vector3[2]
{
RectTransformSnapping.GetInterpolatedCorner(RectTransformSnapping.s_Corners, mainAxis, alongMainAxis, 0.0f),
RectTransformSnapping.GetInterpolatedCorner(RectTransformSnapping.s_Corners, mainAxis, alongMainAxis, 1f)
}));
}
foreach (Transform transform in parentSpace)
{
if (!((Object) transform == (Object) self))
{
RectTransform component = transform.GetComponent<RectTransform>();
if ((bool) ((Object) component))
{
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(component.anchorMin[mainAxis], new Vector3[0]));
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(component.anchorMax[mainAxis], new Vector3[0]));
}
}
}
int num = mainAxis != 0 ? minmaxY : minmaxX;
if (num == 0)
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(gui.anchorMax[mainAxis], new Vector3[0]));
if (num == 1)
RectTransformSnapping.s_SnapGuides[mainAxis].AddGuide(new SnapGuide(gui.anchorMin[mainAxis], new Vector3[0]));
}
}
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:34,代码来源:RectTransformSnapping.cs
示例5: Add
public bool Add(RectTransform child, bool forceAdd = false)
{
bool canAdd = child.rect.width <= AvailableWidth;
if (!canAdd && !forceAdd)
{
return false;
}
UpdateHeightForChild(child);
if (canAdd)
{
child.SetParent(transform, false);
child.SetAsLastSibling();
CurrentWidth += child.rect.width;
}
else
{
GameObject containerObject = new GameObject("LineForceContainer");
RectTransform containerTransformRect = containerObject.AddComponent<RectTransform>();
containerTransformRect.SetParent(transform, false);
containerTransformRect.SetAsLastSibling();
LayoutElement containerLayoutElement = containerObject.AddComponent<LayoutElement>();
containerLayoutElement.preferredWidth = AvailableWidth;
containerLayoutElement.preferredHeight = child.rect.height;
CurrentWidth += containerLayoutElement.preferredWidth;
}
return true;
}
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:33,代码来源:RichEditLine.cs
示例6: UpdatePosition
public void UpdatePosition(RectTransform goToObject)
{
if (goToObject == null) return;
gotoX = goToObject.rect.xMin - (goToObject.rect.width / 2);
gotoY = goToObject.position.y + 0.2f;
}
开发者ID:Midimistro,项目名称:Deadmen,代码行数:7,代码来源:UI_Cursor.cs
示例7: Start
//--------------------------------------------------------------------------------------------
void Start ()
{
// get handle on player script
playerScript = GetComponent<Player> ();
if(playerScript.chassisQuick)
{
rechargeRate *= playerScript.cooldownBoost;
}
energyBar = GameObject.Find("EnergyBar").GetComponent<RectTransform>();
origin = energyBar.localPosition;
energySprites = Resources.LoadAll<Sprite>("GUI_Assets/EnergyIcons");
energyImg = GameObject.Find("EnergyImg").GetComponent<Image>();
blinkCoroutine = null;
//init emp area prefab
empAreaPrefab = Resources.Load<GameObject>("PlayerBullets/EMPArea");
currEnergy = maxEnergy;
isOnCooldown = false;
//get handle on audio source for secondary ready
readyAudio = GetComponents<AudioSource>()[1];
}
开发者ID:zachary-goodless,项目名称:Cull-the-Swarm,代码行数:27,代码来源:EMPManager.cs
示例8: OnBeginDrag
public void OnBeginDrag (PointerEventData eventData)
{
originPos = rt.position;
fatherRT = rt.parent.GetComponent<RectTransform>();
cg.blocksRaycasts = false;
isDrag = true;
}
开发者ID:applexiaohao,项目名称:CardGame,代码行数:7,代码来源:M_FoodMoveScript.cs
示例9: Start
void Start()
{
colRectTransform = itemPrefab.GetComponent<RectTransform> ();
containerRectTransform = gameObject.GetComponent<RectTransform> ();
cardHeight = containerRectTransform.rect.height;
cardWidth = colRectTransform.rect.width;
}
开发者ID:ShaneMcCloskey,项目名称:GameOfLoans,代码行数:7,代码来源:ScrollableList.cs
示例10: Awake
void Awake()
{
foodSprites = new Sprite[foodNum];
orderedName = new string[foodNum];
panelRT = GameObject.FindWithTag ("Panel").GetComponent<RectTransform>() ;
cells = new GameObject[foodNum];
}
开发者ID:applexiaohao,项目名称:CardGame,代码行数:7,代码来源:M_ManagerScript.cs
示例11: Start
void Start ()
{
if(canvas != null){
scaleFactor = canvas.scaleFactor;
}
rect_transform = GetComponent<RectTransform>();
}
开发者ID:PlayFab,项目名称:PlayFabGameServer,代码行数:7,代码来源:PUIResizableWindow.cs
示例12: Start
void Start()
{
tran = GetComponent <RectTransform> ();
sizelength = Mathf.Min (tran.rect.width, tran.rect.height);
Init ();
print (tran.rect);
}
开发者ID:wey521520,项目名称:NewMGC,代码行数:7,代码来源:KeyBoard.cs
示例13: Awake
void Awake()
{
timeLastEnemyHitted = Time.time;
trigger = GetComponentInChildren<BoxCollider>();
sprite = transform.GetComponentInChildren<SpriteRenderer>();
glitchPartPool = new ObjectPool(glitchPart);
lives = 3;
items = 0;
//Instantiate the glitch fragments to avoid lag later in the game
GameObject[] parts = new GameObject[100];
for (int i = 0; i < 100; i++)
{
parts[i] = glitchPartPool.getObject();
}
for (int i = 0; i < 100; i++)
{
parts[i].SetActive(false);
}
boxUIActivatedRectTransform = boxUIActivated.GetComponent<RectTransform>();
exclamationSize = boxUIActivatedRectTransform.sizeDelta;
boxUIActivated.SetActive(false);
guiRectTrans = gui.GetComponent<RectTransform>();
slowFPSScript = transform.FindChild("Powers").GetComponentInChildren<SlowFPS>();
}
开发者ID:TeamGlitch,项目名称:Glitch,代码行数:27,代码来源:Player.cs
示例14: Start
// Use this for initialization
void Start()
{
Invoke("ShowContinueText", 5);
startTime = Time.realtimeSinceStartup;
tScaler = GameObject.Find("Time Manager").GetComponent<TimeScaler>();
boxTransform = GetComponent<RectTransform>();
backgroundTransform = transform.parent.GetComponent<RectTransform>();
gradientTransform = transform.Find("Background Gradient").GetComponent<RectTransform>();
topBorder = transform.Find("Top Border").GetComponent<RectTransform>();
bottomBorder = transform.Find("Bottom Border").GetComponent<RectTransform>();
boxImage = GetComponent<RawImage>();
backgroundImage = transform.parent.GetComponent<RawImage>();
gradientImage = transform.Find("Background Gradient").GetComponent<RawImage>();
topImage = transform.Find("Top Border").GetComponent<RawImage>();
bottomImage = transform.Find("Bottom Border").GetComponent<RawImage>();
iconImage = transform.Find("Info Icon").GetComponent<RawImage>();
tutorialText = transform.Find("Tutorial Text").GetComponent<Text>();
continueText = transform.Find("Continue Text").GetComponent<Text>();
SetStartingColors();
i = 0;
}
开发者ID:redahanb,项目名称:Spectral,代码行数:29,代码来源:TutorialBox.cs
示例15: SetRectAsFullScreen
public static void SetRectAsFullScreen(ref RectTransform targetTrans)
{
targetTrans.anchorMin = Vector2.zero;
targetTrans.anchorMax = Vector2.one;
targetTrans.offsetMin = Vector2.zero;
targetTrans.offsetMax = Vector2.zero;
}
开发者ID:IriskaDev,项目名称:BasicUnityProj,代码行数:7,代码来源:UIUtils.cs
示例16: CreateLayout
public virtual void CreateLayout()
{
allSlots = new List<GameObject>();
emptySlots = slots;
int rows = (int)Mathf.Ceil((float)slots / columns);
inventoryWidth = columns * (slotSize + slotPaddingLeft) + slotPaddingLeft;
inventoryHeight = rows * (slotSize + slotPaddingTop) + slotPaddingTop;
inventoryRect = m_slotContainer.GetComponent<RectTransform>();
for (int i = 0; i < slots; i++) {
GameObject newSlot = Instantiate(PanelManager.Instance.slotPrefab) as GameObject;
newSlot.transform.SetParent(m_slotContainer.transform, false);
newSlot.name = "Slot[" + (i / 4) + "][" + (i % 4) + "]";
RectTransform slotRect = newSlot.GetComponent<RectTransform>();
slotRect.localPosition = new Vector3(slotPaddingLeft * ((i % 4) + 1) + (slotSize * (i % 4)), - slotPaddingTop * ((i / 4) + 1) - (slotSize * (i / 4)));
slotRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, slotSize);
slotRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, slotSize);
allSlots.Add(newSlot);
}
}
开发者ID:ivanrenic,项目名称:inventory-system,代码行数:25,代码来源:Inventory.cs
示例17: Start
void Start()
{
introText = GetComponent<Text>();
introText.text = introTextFile.text;
trans = GetComponent<RectTransform>();
y = trans.anchoredPosition.y;
}
开发者ID:Astha666,项目名称:Time-Journey,代码行数:7,代码来源:GameIntroFallingText.cs
示例18: Awake
void Awake()
{
background = transform.Find("Background").gameObject;
dialogue = transform.Find("Dialogue").gameObject;
backgroundTransform = background.GetComponent<RectTransform>();
dialogueTransform = dialogue.GetComponent<RectTransform>();
}
开发者ID:asacoolguy,项目名称:Immersive-Interaction,代码行数:7,代码来源:SpeechBubbleGenerator.cs
示例19: AddInlineGraphicsChild
public void AddInlineGraphicsChild()
{
if (m_inlineGraphic != null)
{
//Debug.LogWarning("A child Inline Graphics object already exists.");
return;
}
GameObject inlineGraphicObj = new GameObject("Inline Graphic");
m_inlineGraphic = inlineGraphicObj.AddComponent<InlineGraphic>();
m_inlineGraphicRectTransform = inlineGraphicObj.GetComponent<RectTransform>();
m_inlineGraphicCanvasRenderer = inlineGraphicObj.GetComponent<CanvasRenderer>();
m_inlineGraphicRectTransform.SetParent(transform, false);
m_inlineGraphicRectTransform.localPosition = Vector3.zero;
m_inlineGraphicRectTransform.anchoredPosition3D = Vector3.zero;
m_inlineGraphicRectTransform.sizeDelta = Vector2.zero;
m_inlineGraphicRectTransform.anchorMin = Vector2.zero;
m_inlineGraphicRectTransform.anchorMax = Vector2.one;
m_TextMeshPro = gameObject.GetComponent<TextMeshPro>();
m_TextMeshProUI = gameObject.GetComponent<TextMeshProUGUI>();
}
开发者ID:SamSeidenberg,项目名称:DGames,代码行数:25,代码来源:InlineGraphicManager.cs
示例20: Start
// Use this for initialization
void Start () {
ThisRect = GetComponent<RectTransform>();
if (ThisRect == null) return;
gotoX = ThisRect.rect.x;
gotoY = ThisRect.rect.y;
}
开发者ID:Midimistro,项目名称:Deadmen,代码行数:8,代码来源:UI_Cursor.cs
注:本文中的UnityEngine.RectTransform类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论