本文整理汇总了C#中UnityEngine.RectTransform.GetComponentInChildren方法的典型用法代码示例。如果您正苦于以下问题:C# RectTransform.GetComponentInChildren方法的具体用法?C# RectTransform.GetComponentInChildren怎么用?C# RectTransform.GetComponentInChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.RectTransform
的用法示例。
在下文中一共展示了RectTransform.GetComponentInChildren方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResizeButton
private void ResizeButton (RectTransform _rect)
{
float screenX = 800;
float screenY = 480;
float rectWidth = (_rect.sizeDelta.x / screenX) * Screen.width;
float rectHeight = (_rect.sizeDelta.y / screenY) * Screen.height;
_rect.sizeDelta = new Vector2 (rectWidth, rectHeight);
float rectX = (_rect.anchoredPosition.x / screenX) * Screen.width;
float rectY = (_rect.anchoredPosition.y / screenY) * Screen.height;
_rect.anchoredPosition = new Vector2 (rectX, rectY);
int size = _rect.GetComponentInChildren<Text> ().fontSize;
_rect.GetComponentInChildren<Text> ().fontSize = (int)(size * (Screen.width / screenX));
}
示例2: 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;
}
示例3: Start
void Start()
{
healthBarCanvas = GameObject.Find("Health Bar Canvas").transform;
hpSource = this.GetComponent<IHealth>();
_healthBarInstance = GameObject.Instantiate(healthBarPrefab);
_healthBarInstance.SetParent(healthBarCanvas, false);
healthBarSlider = _healthBarInstance.GetComponentInChildren<Slider>();
healthBarPos = this.transform.position;
healthBarPos.y += healthBarHeight;
_healthBarInstance.anchoredPosition = Camera.main.WorldToScreenPoint(healthBarPos);
}
示例4: Awake
void Awake()
{
m_TextMeshPro = gameObject.GetComponent<TextMeshProUGUI>();
m_Canvas = gameObject.GetComponentInParent<Canvas>();
// Get a reference to the camera if Canvas Render Mode is not ScreenSpace Overlay.
if (m_Canvas.renderMode == RenderMode.ScreenSpaceOverlay)
m_Camera = null;
else
m_Camera = m_Canvas.worldCamera;
// Create pop-up text object which is used to show the link information.
m_TextPopup_RectTransform = Instantiate(TextPopup_Prefab_01) as RectTransform;
m_TextPopup_RectTransform.SetParent(m_Canvas.transform, false);
m_TextPopup_TMPComponent = m_TextPopup_RectTransform.GetComponentInChildren<TextMeshProUGUI>();
m_TextPopup_RectTransform.gameObject.SetActive(false);
}
示例5: Start
void Start()
{
currentStep = PlayerHistoryStep.HELLCIRCLE;
HistorySelection = GetComponent<Canvas> ();
HistoChoiceDescription = HistorySelection.GetComponentInChildren<RectTransform> ();
ChoiceDisplay = HistoChoiceDescription.GetComponentInChildren<GridLayoutGroup> ();
for (int i=0; i<9; i++) {
Choice [i] = ChoiceDisplay.GetComponentsInChildren<Button> () [i];
}
for (int i=0; i<10; i++) {
HistoryChoiceDisplay [i] = HistorySelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Text> () [i];
}
for (int i=0; i<9; i++) {
HistoryChoiceImage [i] = HistorySelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Image> () [i + 1];
}
GetHistoryUIButtons ();
HistorySelection.enabled = false;
}
示例6: LoadCoroutine
private IEnumerator LoadCoroutine()
{
int i = 0;
foreach (FileInfo f in info)
{
item = Instantiate(prefab) as RectTransform;
item.SetParent(transform, false);
Text titleText = item.GetComponentInChildren<Text>();
titleText.text = f.Name.Substring(0, f.Name.Length - 5);
item.gameObject.GetComponent<LoadButtonParam>().Number = i++;
_loadButtonParam = item.gameObject.GetComponent<LoadButtonParam>();
string folderPath = "";
try
{
if (Application.platform != RuntimePlatform.WindowsEditor)
{
folderPath = Application.persistentDataPath + "/" + titleText.text + ".png";
}
else if(Application.platform == RuntimePlatform.OSXEditor)
{
folderPath = Application.dataPath + "/../" + titleText.text + ".png";
}else
{
folderPath = Application.dataPath + "/../" + titleText.text + ".png";
}
byte[] by = File.ReadAllBytes(folderPath);
Texture2D tex = new Texture2D(0, 0);
tex.LoadImage(by);
GameObject sun = item.transform.FindChild("ScreenShot").gameObject;
Image image = sun.GetComponent<Image>();
image.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height),Vector2.zero);
}
catch (Exception e)
{
print(e.Message);
}
yield return null;
}
}
示例7: UpdateSubroutineButtonText
private void UpdateSubroutineButtonText(RectTransform r, string compositeName)
{
r.GetComponentInChildren<Text>().text = compositeName;
}
示例8: setPlayersNames
void setPlayersNames(GameModel game, RectTransform gameCanvas) {
PlayerLeftNameScript playerLeftName;
PlayerRightNameScript playerRightName;
// set players names
playerLeftName = gameCanvas.GetComponentInChildren<PlayerLeftNameScript>();
if (playerLeftName != null) {
playerLeftName.setName(game.players.challenger.username);
}
playerRightName = gameCanvas.GetComponentInChildren<PlayerRightNameScript>();
if (playerRightName != null) {
playerRightName.setName(game.players.challenged.username);
}
}
示例9: setTurn
void setTurn(GameModel game, RectTransform gameCanvas) {
GameTurnUpdateScript turnDisplay;
// set players names
turnDisplay = gameCanvas.GetComponentInChildren<GameTurnUpdateScript>();
turnDisplay.setTurn (game.turn);
}
示例10: setPayload
void setPayload(GameModel game, RectTransform gameCanvas) {
GamePayloadScript gamePayload;
// set players names
gamePayload = gameCanvas.GetComponentInChildren<GamePayloadScript>();
gamePayload.gameId = game._id;
}
示例11: Awake
void Awake() {
_textField = GetComponent<Text>();
_windowTransform = GameObject.FindGameObjectWithTag("ConsoleWindow").GetComponent<RectTransform>();
_scrollbar = _windowTransform.GetComponentInChildren<Scrollbar>();
}
示例12: AddButton
private void AddButton(Action onClick, RectTransform buttonInst)
{
var image = buttonInst.GetComponentInChildren<Image>();
image.gameObject.SetActive(false);
Buttons.Add(new ButtonData()
{
Trans = (RectTransform)buttonInst.transform,
HightlighEffect = image,
OnClick = onClick,
});
}
示例13: Start
void Start()
{
PreDefinedSelection = GetComponent<Canvas> ();
data.Load(CSVSource);
HistoChoiceDescription = PreDefinedSelection.GetComponentInChildren<RectTransform> ();
ChoiceDisplay = HistoChoiceDescription.GetComponentInChildren<GridLayoutGroup> ();
for (int i=0; i<9; i++) {
Choice [i] = ChoiceDisplay.GetComponentsInChildren<Button> () [i];
}
for (int i=0; i<9; i++) {
HistoryChoiceImage [i] = PreDefinedSelection.GetComponentInChildren<Mask> ().GetComponentsInChildren<Image> () [i + 1];
}
for (int i = 0; i < 9; i++)
GetPreDefinedUIButtons ();
PreDefinedSelection.enabled = false;
}
示例14: Update
private void Update()
{
if (m_LastEnabled != m_Interactable)
{
m_LastEnabled = m_Interactable;
if (canvasGroup != null)
{
if (m_LastEnabled)
{
canvasGroup.blocksRaycasts = true;
canvasGroup.alpha = 1f;
if (m_DisabledPanel != null)
{
Destroy(m_DisabledPanel.gameObject);
}
}
else
{
canvasGroup.blocksRaycasts = false;
canvasGroup.alpha = 0.15f;
if (m_ShowDisabledPanel)
{
m_DisabledPanel = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.disabledPanel, rectTransform).GetComponent<RectTransform>();
m_DisabledPanel.anchoredPosition = Vector2.zero;
m_DisabledPanel.sizeDelta = Vector2.zero;
Color backgroundColor = tabView.GetComponent<Image>().color;
m_DisabledPanel.GetComponent<Image>().color = backgroundColor;
m_DisabledPanel.GetComponentInChildren<Text>().color =
(backgroundColor.r + backgroundColor.g + backgroundColor.b) / 3 > 0.8f
? MaterialColor.textDark
: MaterialColor.textLight;
}
}
}
}
}