本文整理汇总了C#中UnityEngine.RectTransform.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# RectTransform.GetComponent方法的具体用法?C# RectTransform.GetComponent怎么用?C# RectTransform.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.RectTransform
的用法示例。
在下文中一共展示了RectTransform.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FadeInPanel
public RectTransform FadingOutPanel; //Reference to panel that is currently fading out
#endregion Fields
#region Methods
/// <summary>
/// Fade in panel
/// </summary>
/// <param name="panel">Panel to fade in</param>
/// <returns></returns>
public IEnumerator FadeInPanel(RectTransform panel)
{
FadingInPanel = panel;
FadingInPanel.gameObject.SetActive(true);
while(panel.GetComponent<CanvasGroup>().alpha < 1)
{
panel.GetComponent<CanvasGroup>().alpha += Time.deltaTime / FadeTime;
yield return null;
}
ActivePanel = panel;
FadingInPanel = null;
}
示例2: FadeOutPanel
/// <summary>
/// Fade out panel
/// </summary>
/// <param name="panel">Panel to fade out</param>
/// <returns></returns>
public IEnumerator FadeOutPanel(RectTransform panel)
{
FadingOutPanel = panel;
ActivePanel = null;
while (panel.GetComponent<CanvasGroup>().alpha > 0)
{
panel.GetComponent<CanvasGroup>().alpha -= Time.deltaTime / FadeTime;
yield return null;
}
FadingOutPanel.gameObject.SetActive(false);
FadingOutPanel = null;
}
示例3: Initialize
public override void Initialize()
{
battleSelection = transform.root.GetComponent<BattleSelection> ();
Canvas canvas = transform.FindChild ("BattleCanvas").GetComponent<Canvas>();
foreach(GameObject g in GameObject.FindGameObjectsWithTag("Canvas")){
g.SetActive(false); //set all other canvases inactive to be sure
}
canvas.gameObject.SetActive (true); //activate the canvas we want
if (!initialized) {
if (canvas != null) { //is this nessisary? probs not because I think that setactive call above will throw an exception
leftPanel = canvas.transform.FindChild ("Left Panel").GetComponent<RectTransform> ();
mothershipLeftPanel = canvas.transform.FindChild ("Mothership Left Panel").GetComponent<RectTransform> ();
mothershipPanel = mothershipLeftPanel.GetComponent<BattleMothershipPanel> ();
infoPanel = leftPanel.GetComponent<BattleInfoPanel> ();
infoPanel.Initialize ();
mothershipPanel.Initialize ();
timer = GetComponent<Timer> ();
jumpbutton = GameObject.Find ("BattleCanvas/Top Panel/JumpButton");
jumpbutton.SetActive (false);
initialized = true;
} else {
Debug.Log ("Null canvas for Battle?");
}
}
}
示例4: SwitchTo
public void SwitchTo(RectTransform new_panel)
{
if (ActivePanel)
{
if (ActivePanel == new_panel)
return;
if (ActivePanel.GetComponent<CanvasGroup>())
PanelUtilities.DeactivatePanel(ActivePanel.GetComponent<CanvasGroup>());
}
ActivePanel = new_panel;
if (ActivePanel.GetComponent<CanvasGroup>())
PanelUtilities.ActivatePanel(ActivePanel.GetComponent<CanvasGroup>());
}
示例5: Start
// Use this for initialization
void Start () {
penX.onValueChange.AddListener(ChangePenX);
penY.onValueChange.AddListener(ChangePenY);
brushX.onValueChange.AddListener(ChangeBrushX);
brushY.onValueChange.AddListener(ChangeBrushY);
bSize.onValueChange.AddListener(ChangeBSize);
penX.text = PlayerPrefs.GetInt("penOffsetX", 0).ToString();
penY.text = PlayerPrefs.GetInt("penOffsetY", 0).ToString();
brushX.text = PlayerPrefs.GetInt("brushOffsetX", 0).ToString();
brushY.text = PlayerPrefs.GetInt("brushOffsetY", 0).ToString();
bSize.text = PlayerPrefs.GetInt("bSize", 10).ToString();
var detector = DrawUtility.CreateDetector(prefab);
detector.OnStartPaint += new PaintingDetector2D.DelegatePaint(OnStartPaint);
detector.OnPaintMovement += new PaintingDetector2D.DelegatePaint(OnPaintMovement);
detector.OnPaintEnd += new PaintingDetector2D.DelegatePaint(OnPaintEnd);
drawRect = DrawUtility.CreateRectTransform(prefab, new Vector2(Screen.width, Screen.height));
drawImage = drawRect.GetComponent<RawImage>();
paintTexture = DrawUtility.CreateCanvas(Screen.width, Screen.height);
drawImage.texture = paintTexture;
btn.onClick.AddListener(Click);
}
示例6: Start
void Start()
{
mRectTransform = this.transform as RectTransform;
_btn = mRectTransform.GetComponent<Button>();
_mask = mRectTransform.Find("mask").GetComponent<Image>();
_mask.transform.localPosition = Vector3.zero;
_mask.enabled = false;
}
示例7: Awake
void Awake()
{
panelTournament = transform.FindChild("PanelTournament") as RectTransform;
panelNormal = transform.FindChild("PanelNormal") as RectTransform;
panelPlayerList = transform.FindChild("PanelPlayerList") as RectTransform;
panelChatBox = transform.FindChild("PanelChatBox") as RectTransform;
chatBox = panelChatBox.GetComponent<ChatBoxControl>();
}
示例8: getView
public override RectTransform getView(RectTransform currentView, int position)
{
if (currentView == null) {
currentView = Instantiate(prefab);
}
Text text = currentView.GetComponent<Text>();
text.text = textList[position] + " pos=" + position;
return currentView;
}
示例9: MoveScene
void MoveScene(RectTransform obj,int scnarioNumber)
{
Button button = obj.GetComponent<Button> ();
button.onClick.AddListener (() => {
NovelSingleton.StatusManager.callJoker("wide/scene"+ scnarioNumber,"");
});
}
示例10: Start
void Start()
{
internalRect = transform.FindChild ("Internal").GetComponent<RectTransform>();
externalRect = transform.FindChild ("External").GetComponent<RectTransform>();
internalButtons = internalRect.GetComponent<ButtonOrganizer> ();
externalButtons = externalRect.GetComponent<ButtonOrganizer> ();
attachmentPanel = PrefabLoader.GetGUIObject ("AttachmentPanel");
userInput = transform.root.GetComponent<ShipEditorUserInput> ();
}
示例11: Start
protected override void Start ()
{
PlaceHolder = transform.GetChild(0) as RectTransform;
PlaceHolder.GetComponent<Image>().sprite = imageButteon.sprite;
rectTransf = transform as RectTransform;
menu = rectTransf.parent.GetComponent<CirculareMenu>();
isStarted = true;
}
示例12: Start
public void Start() {
// get components
canvas = GameObject.Find("StatUI").GetComponent<RectTransform>();
game = canvas.GetComponent<Game>();
model = transform.Find("Model").transform;
player = GameObject.Find("Player").transform;
nav = GetComponent<NavMeshAgent>();
nav.speed = Random.Range(2.0f, 5.5f);
// build healthbar
GameObject backGO = new GameObject("healthbarback");
backGO.transform.parent = canvas.Find("HealthBars").transform;
GameObject healthGO = new GameObject("healthbar");
healthGO.transform.parent = canvas.Find("HealthBars").transform;
healthBar = healthGO.AddComponent<Image>();
backBar = backGO.AddComponent<Image>();
healthBar.color = Color.red;
backBar.color = new Color(0.2f, 0.0f, 0.0f);
healthBar.rectTransform.sizeDelta = new Vector2(100, 5);
backBar.rectTransform.sizeDelta = new Vector2(100, 5);
backBar.rectTransform.pivot = Vector2.zero;
healthBar.rectTransform.pivot = Vector2.zero;
switch (type) {
case EnemyType.ORC:
hp = 2.0f + game.level;
damage = 2.0f + game.level;
break;
case EnemyType.SKELETON:
hp = 0.5f + game.level / 3.0f;
damage = 1.0f + (game.level) / 3.0f;
break;
case EnemyType.MAGE:
hp = 1.0f + game.level / 3.0f;
damage = 2.5f + game.level / 2.0f;
break;
case EnemyType.RANGER:
hp = 1.0f + game.level / 2.0f;
damage = 1.0f + game.level / 2.0f;
break;
case EnemyType.CROSSBOW:
hp = 1.0f + game.level / 1.5f;
damage = 1.0f + game.level / 2.0f;
break;
default:
hp = 1.0f + game.level / 2.0f;
damage = 1.0f + game.level / 2.0f;
break;
}
maxhp = hp;
}
示例13: Awake
void Awake()
{
On("OnMainCameraChange");
_healthContainer = GetComponentInChildren<Image>().gameObject;
_healthContainer.GetComponentInParent<Canvas>().worldCamera = Camera.main;
_rectTransform = _healthContainer.GetComponent<RectTransform>();
_healthBar = _healthContainer.transform.FindChild("HealthBar").GetComponent<RectTransform>();
_image = _healthBar.GetComponent<Image>();
_krHealth = transform.GetComponentInParent<KRHealth>();
}
示例14: Summon
//summon activates whenever a card is played. All spells (at least for now) target a specific tile.
public override Transform Summon(RectTransform location, Transform hand)
{
if (location.GetComponent<Tile_Component>().unit != null)
location.GetComponentInChildren<BaseUnit_Component>().TakeDamage(5);
else
{
hand.GetComponent<ResourceManager>().AddResources(cost);
hand.GetComponent<Hand_Component>().AddCard(0003);
}
return transform;
}
示例15: Summon
//summons a creature
public override Transform Summon(RectTransform tile, Transform hand)
{
Transform thisGuy = Instantiate(transform);
tile.GetComponent<Tile_Component>().unit = thisGuy.GetComponent<RectTransform>();
thisGuy.transform.SetParent(tile, false);
health = maxHealth;
attack = baseAttack;
countdown = baseCountdown;
return transform;
}