本文整理汇总了C#中UnityEngine.RectTransform.Find方法的典型用法代码示例。如果您正苦于以下问题:C# RectTransform.Find方法的具体用法?C# RectTransform.Find怎么用?C# RectTransform.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.RectTransform
的用法示例。
在下文中一共展示了RectTransform.Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
public override void Awake()
{
base.Awake();
gameObject.SetActive(false);
contentPanel = (RectTransform)transform.Find("ContentPanel");
scroller = transform.Find("Scrollbar").GetComponent<Scrollbar>();
messageBox = new MessageBox(transform.Find("MessageBox"));
scroller.onValueChanged.AddListener(delegate(float value)
{
float screenHeight = Screen.height;
float screenWidth = Screen.width;
float allHeight = contentPanel.rect.height - screenHeight + 50f;
float allWidth = contentPanel.rect.width;
float yPos = value * -allHeight + allHeight / 2f + screenHeight / 2f;
float xPos = (screenWidth - allWidth) / 2f + allWidth / 2;
contentPanel.position = new UnityEngine.Vector2(xPos, yPos);
});
RectTransform userInfoPanel = (RectTransform)contentPanel.Find("UserInfoPanel");
firstNameText = userInfoPanel.Find("UserNameText").GetComponent<Text>();
secondNameText = userInfoPanel.Find("UserLavelText").GetComponent<Text>();
userIconImage = userInfoPanel.Find("UserIcon").GetComponent<Image>();
avalableGamesPanel = (RectTransform)contentPanel.Find("AvalableGamesPanel");
}
示例2: Init
private void Init()
{
_mRectTransform = this.transform as RectTransform;
_imgBall1 = _mRectTransform.Find("Image_ball/ball1").GetComponent<Image>();
_imgBall2 = _mRectTransform.Find("Image_ball/ball2").GetComponent<Image>();
_imgBall3 = _mRectTransform.Find("Image_ball/ball3").GetComponent<Image>();
ResetBall();
}
示例3: Awake
private void Awake()
{
Delegates.CurrentTeamColorChanged += RefreshColor;
Delegates.ScreenSizeChanged += RefreshEntryRect;
(entry = GetComponent<RectTransform>()).SetParent(GameObject.Find("ProductionLists").transform);
description = entry.Find("Description").GetComponent<Text>();
tintedIcon = entry.Find("TintedIcon").GetComponent<Image>();
underlay = entry.Find("Underlay").GetComponent<Image>();
}
示例4: 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;
}
示例5: Init
private void Init()
{
_mRectTransform = this.transform as RectTransform;
_bar = _mRectTransform.Find("bar").GetComponent<Image>();
_count = _mRectTransform.Find("count");
//gameObject.SetActive(false);
//StartCombo();
/*Type T = Type.GetType("Game.EnityData");
MemberInfo[] _a = T.GetMember("DictActionTime");*/
}
示例6: Start
// Use this for initialization
void Start () {
//Enemy killed counter initialisation
text = GetComponentInChildren<Text>();
text.text = ("Enemies killed : " + enemiesKilled);
GameObject player = GameObject.FindGameObjectWithTag("Player");
health = player.GetComponent<HealthScript>();
playerHealth = health.health;
totalHealth = playerHealth;
weapon = player.GetComponent<WeaponController>();
skill = player.GetComponent<SkillController>();
GameObject skills = GameObject.Find("Skills");
//skills.gameObject.
GameObject bullet = GameObject.Find("Bullet");
bulletCooldownBar = bullet.GetComponentInChildren<RectTransform>();
bulletCooldownBar = bulletCooldownBar.FindChild("Cooldown") as RectTransform;
GameObject secondary = GameObject.Find("Secondary");
secondaryCooldownBar = secondary.GetComponentInChildren<RectTransform>();
secondaryCooldownBar = secondaryCooldownBar.FindChild("Cooldown") as RectTransform;
GameObject dodge = GameObject.Find("Dodge");
dodgeCooldownBar = dodge.GetComponentInChildren<RectTransform>();
dodgeCooldownBar = dodgeCooldownBar.Find("Cooldown") as RectTransform;
Image healthBarImage = GetComponentInChildren<Image>();
healthBar = healthBarImage.gameObject.GetComponent<RectTransform>();
}
示例7: Init
private void Init()
{
m_transform = this.transform as RectTransform;
img_word1 = m_transform.Find("img_word1").GetComponent<Image>();
img_word2 = m_transform.Find("img_word2").GetComponent<Image>();
img_top = m_transform.Find("img_top").GetComponent<Image>();
img_bottom = m_transform.Find("img_bottom").GetComponent<Image>();
img_top.rectTransform.anchoredPosition = new Vector2(0, 0);
img_bottom.rectTransform.anchoredPosition = new Vector2(0, 0);
img_word1.rectTransform.anchoredPosition = new Vector2(-180, 0);
img_word2.rectTransform.anchoredPosition = new Vector2(180, 0);
m_transform.sizeDelta = new Vector2(400, 0);
m_transform.anchoredPosition = new Vector2(0, 200);
gameObject.SetActive(false);
this.Invoke("PlayEffect", 1f);
}
示例8: 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;
}
示例9: Init
private void Init()
{
m_transfrom = this.transform as RectTransform;
Transform _btns = m_transfrom.Find("btn_container");
btn_atk = _btns.Find("btn_atk").GetComponent<Button>();
btn_skill1 = _btns.Find("btn_skill1").GetComponent<Button>();
btn_skill2 = _btns.Find("btn_skill2").GetComponent<Button>();
btn_skill3 = _btns.Find("btn_skill3").GetComponent<Button>();
btn_skill4 = _btns.Find("btn_skill4").GetComponent<Button>();
_arrBtns = new Button[5] { btn_atk, btn_skill1, btn_skill2, btn_skill3, btn_skill4 };
}
示例10: PutInInventory
private void PutInInventory(RectTransform panel, Toggle sender)
{
string selectedID = panel.Find("Panel/ItemStaticID").GetComponentInChildren<Text>().text;
Destroy(panel.gameObject);
Equipment e = itemDatabase.GetCopyEquipment(selectedID);
CurrentPlayer.currentPlayer.PlayerInventory.AddEquipment(e);
Destroy(GameObject.Find("ItemTooltip(Clone)").gameObject);
}
示例11: PutInInventory
private void PutInInventory(RectTransform panel, Toggle sender)
{
string staticID = panel.Find("Panel/ItemStaticID").GetComponentInChildren<Text>().text;
Destroy(panel.gameObject);
Equipment e = itemDatabase.GetCopyEquipment(staticID);
CurrentPlayer.currentPlayer.PlayerInventory.AddEquipment(e);
information.RemoveFromDropLoot(staticID);
Destroy(GameObject.Find("ItemTooltip(Clone)").gameObject);
numberOfLoot--;
if (numberOfLoot == 0) //ako vise nema nicega za lootanje, disable skriptu
{
Destroy(gameObject.transform.parent.gameObject);
}
}
示例12: loadAssets
public void loadAssets()
{
if (m_rect == null ||
m_title == null ||
m_parameters == null ||
m_viewport == null ||
m_content == null
)
{
m_layoutElem = GetComponent<LayoutElement>();
m_rect = (RectTransform)transform;
m_title = transform.Find("title_panel").GetComponent<RectTransform>();
m_parameters = transform.Find("parameters").GetComponent<RectTransform>();
m_viewport = m_parameters.Find("viewport").GetComponent<RectTransform>();
m_content = m_viewport.Find("content").GetComponent<RectTransform>();
m_upScroll = transform.Find("scroll_up").GetComponent<RectTransform>();
m_downScroll = transform.Find("scroll_down").GetComponent<RectTransform>();
}
}
示例13: Awake
void Awake()
{
if (instance == null)
instance = this;
else if (instance != this)
Destroy (gameObject);
cam = Camera.main;
player=GameObject.Find("Player").GetComponent<Player>();
scorePanel=GameObject.Find("Panel_Score").GetComponent<RectTransform>();
boardScript=GetComponent<BoardManager>();
inputHandler=GetComponent<InputHandler>();
dataFetcher=GetComponent<DataFetcher>();
scoreSlider = scorePanel.Find("Slider_Score").GetComponent<Slider>();
livesSlider = scorePanel.Find("Slider_lives").GetComponent<Slider>();
levelText=GameObject.Find("level").GetComponent<Text>();
levelDesc=GameObject.Find("level_desc").GetComponent<Text>();
scoreText = scorePanel.Find("Text_Score").GetComponent<Text>();
sceneEnd = GameObject.Find ("scene_end").GetComponent<Image>();
bRestart= GameObject.FindWithTag ("Respawn").GetComponent<Button>();
bRestart.gameObject.SetActive (false);
bResume= GameObject.FindWithTag ("Resume").GetComponent<Button>();
bResume.gameObject.SetActive (false);
bPause= GameObject.FindWithTag ("Pause").GetComponent<Button>();
//bPause.gameObject.SetActive (false);
bExit= GameObject.FindWithTag ("Finish").GetComponent<Button>();
bExit.gameObject.SetActive (false);
bSoundOn= GameObject.Find ("sound_on").GetComponent<Button>();
bSoundOn.gameObject.SetActive (false);
bSoundOff= GameObject.Find ("sound_off").GetComponent<Button>();
bSoundOff.gameObject.SetActive (false);
debug=GameObject.Find("debug").GetComponent<Text>();
sound= GetComponent<AudioSource>();
initGame ();
if (Screen.width > Screen.height)
camerazoom = 8;
StartCoroutine("cameraZoomIn");
highS = PlayerPrefs.GetInt ("high_score");
}
示例14: _InitRoomUI
private void _InitRoomUI( )
{
m_tf = transform.rectTransform();
m_menuTf = m_tf.Find("menu").GetChild(0);
m_menuButtonTf = m_tf.Find("menu").GetChild(1);
m_menuCanvasGroup = m_menuTf.GetComponent<CanvasGroup>();
}
示例15: Awake
public override void Awake()
{
base.Awake();
gameObject.SetActive(true);
myInfoWindiow = (RectTransform)transform.Find("MyWindow");
usersWindow = (RectTransform)transform.Find("UsersWindow");
RectTransform dataWindow = (RectTransform)transform.Find("DataWindow");
messagesWindow = (RectTransform)dataWindow.Find("MessagesPanel");
sendControlsPanel = (RectTransform)dataWindow.Find("ControlsPanel");
messagesList = (RectTransform)messagesWindow.Find("MessagesList");
messagesListScroller = messagesWindow.Find("MessagesScrollbar").GetComponent<Scrollbar>();
messagesListScroller.onValueChanged.AddListener(delegate(float value)
{
float listHeight = messagesList.rect.height;
float windowHeight = ((RectTransform)messagesListScroller.transform).rect.height;
if (listHeight > windowHeight)
{
float yPos = (listHeight / -2f) + value * (listHeight - windowHeight);
messagesList.anchoredPosition = new UnityEngine.Vector2(usersList.anchoredPosition.x, yPos);
}
});
sendMessageButton = sendControlsPanel.Find("SendButton").GetComponent<Button>();
sendMessageButton.onClick.AddListener(onSendMessageClick);
sendMessageInputField = sendControlsPanel.Find("InputField").GetComponent<InputField>();
usersList = (RectTransform)usersWindow.Find("UsersList");
usersListScroller = usersWindow.Find("UsersListScroller").GetComponent<Scrollbar>();
usersListScroller.onValueChanged.AddListener(delegate(float value)
{
float listHeight = usersList.rect.height;
float windowHeight = ((RectTransform)usersListScroller.transform).rect.height;
if (listHeight > windowHeight)
{
float yPos = (listHeight / -2f) + value * (listHeight - windowHeight);
usersList.anchoredPosition = new UnityEngine.Vector2(usersList.anchoredPosition.x, yPos);
}
});
startWait();
}