本文整理汇总了C#中Canvas.GetComponentInChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.GetComponentInChildren方法的具体用法?C# Canvas.GetComponentInChildren怎么用?C# Canvas.GetComponentInChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.GetComponentInChildren方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
_highScoreCanvas = GetComponentInChildren<Canvas>();
PlayerNameInputText = _highScoreCanvas.GetComponentInChildren<InputField>();
if(PlayerNameInputText != null)
{
Text[] inputTexts = PlayerNameInputText.gameObject.GetComponentsInChildren<Text>();
foreach(Text t in inputTexts)
{
if (t.name == "Placeholder") t.text = UsersData.DEFAULT_NAME;
}
}
Text[] texts = _highScoreCanvas.GetComponentsInChildren<Text>();
foreach(Text t in texts)
{
t.fontSize = (int)(t.fontSize * ((Screen.width) / 1236f));
if (t.name.Contains("Player Name")) RankPlayerNameText = t;
else if(t.name.Contains("Scores")) RankScoreText = t;
}
obj_localHighScore = LocalHighScore.getInstance();
obj_localHighScore.setMaxUser(maxNumOfUsers);
minScore = obj_localHighScore.getMinScore();
LoadScores();
}
示例2: Awake
void Awake()
{
saved = false;
actor = gameObject.GetComponent<Actor> ();
dialogueCanvas = GameObject.Find ("DialougeCanvas").GetComponent<Canvas> ();
canvasText = dialogueCanvas.GetComponentInChildren<Text> ();
dialogueCanvas.gameObject.SetActive (false);
}
示例3: Awake
void Awake()
{
#region Initialize stuff
currentHealth = Hp;
HealthBar = this.GetComponentInChildren<Canvas>();
HealthBar.name = "HealthBar_" + this.gameObject.name;
//HealthBar.transform.parent = null;
HealthBar.transform.SetParent(null, false);
m_hHpSlider = HealthBar.GetComponentInChildren<Slider>();
m_hSliderRectTransform = m_hHpSlider.GetComponent<RectTransform>();
//m_hDisassembler = GetComponent<MeshDisassembler>();
m_hRigidbody = GetComponent<Rigidbody>();
m_hController = GetComponent<IControllerPlayer>() as MonoBehaviour;
m_hProvider = GetComponent<InputProviderPCStd>();
m_hWeapon = GetComponent<IWeapon>() as MonoBehaviour;
m_hRenderers = new List<Renderer>(GetComponents<Renderer>());
m_hRenderers.AddRange(GetComponentsInChildren<Renderer>());
m_hColliders = new List<Collider>(GetComponents<Collider>());
m_hColliders.AddRange(GetComponentsInChildren<Collider>());
m_hBomb = GetComponent<DeathBomb>();
m_hAudioCtrl = this.GetComponent<MadMaxCarAudio>();
impactCoolDownActors = new LinkedList<MadMaxActor>();
PlayableCenterOfMass = m_hRigidbody.centerOfMass;
wheels = GetComponent<ControllerWheels>();
//dmgImgMGR = GameManager.Instance.GetComponentInChildren<DMGImageMGR>();
CanTakeDamage = true;
#endregion
if (HpBarMode == HealthBarMode.WorldSpace)
{
HealthBar.renderMode = RenderMode.WorldSpace;
}
else
{
HealthBar.renderMode = RenderMode.ScreenSpaceOverlay;
}
}
示例4: Awake
void Awake()
{
directory = "/Resources/SaveGames";
saveGames = new List<SaveGame>();
canvas = GetComponentInChildren<Canvas>();
image = canvas.GetComponentInChildren<Image>().sprite;
buttonSpace = 8;
if(!Directory.Exists(Application.dataPath + directory))
{
Directory.CreateDirectory(Application.dataPath + directory);
}
DirectoryInfo dir = new DirectoryInfo(Application.dataPath + directory);
FileInfo[] info = dir.GetFiles("*.xml");
foreach(FileInfo fileInfo in info)
{
SaveGame saveGame = new SaveGame(fileInfo.Name.Replace(".xml", ""), fileInfo.FullName, fileInfo.DirectoryName + "/" + fileInfo.Name.Replace(".xml", ""));
saveGames.Add(saveGame);
int ID = System.Array.IndexOf(info, fileInfo);
CreateSaveGameButtons(saveGame, ID);
}
}
示例5: Start
public void Start()
{
this.Client = GameObject.Find("Network").GetComponent<Client>();
this.Client.MessageDisturbanceEvent += Client_MessageDisturbanceEvent;
this.Client.MessageSystemEndOfGameEvent += Client_MessageSystemEndOfGameEvent;
Vector3 harborPosition;
switch (this.nameMinorIsland)
{
case "sous_ile_1":
harborPosition = new Vector3(-83, 84, -3);
break;
case "sous_ile_2":
harborPosition = new Vector3(130, 110, -3);
break;
case "sous_ile_3":
harborPosition = new Vector3(-107, -69, -3);
break;
default:
harborPosition = new Vector3(106, -71, -3);
break;
}
buildingManager.createBuilding(TypeBuilding.Harbor, harborPosition);
if (nameMinorIsland == "sous_ile_1")
{
Canvas startCanvasPrefab = Resources.Load<Canvas>("Prefab/StartCanvas");
startCanvas = Instantiate(startCanvasPrefab);
startCanvas.name = "StartCanvas";
Color color = startCanvas.GetComponentInChildren<SpriteRenderer>().color;
color.a = 1;
startCanvas.GetComponentInChildren<SpriteRenderer>().color = color;
StartCoroutine(this.startFade());
}
}
示例6: BlankScreen
public BlankScreen(Color color)
{
GameObject o = GameObject.Find("ScreenFade");
if (o != null)
{
canvas = o.GetComponent<Canvas>();
screen = canvas.GetComponentInChildren<Image>();
}
else
{
canvas = new GameObject("ScreenFade").AddComponent<Canvas>();
screen = new GameObject("Fader").AddComponent<Image>();
}
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
screen.transform.SetParent(canvas.transform);
screen.rectTransform.anchorMax = new Vector2(1, 1);
screen.rectTransform.anchorMin = new Vector2(0, 0);
screen.rectTransform.offsetMax = new Vector2(0, 0);
screen.rectTransform.offsetMin = new Vector2(0, 0);
screen.color = color;
}
示例7: 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;
}
示例8: Update
void Update()
{
if (!ended)
{
if (GameObject.Find("sous_ile_1").GetComponent<Tuto_MinorIsland>().harborRemoved &&
GameObject.Find("sous_ile_2").GetComponent<Tuto_MinorIsland>().harborRemoved &&
GameObject.Find("sous_ile_3").GetComponent<Tuto_MinorIsland>().harborRemoved &&
GameObject.Find("sous_ile_4").GetComponent<Tuto_MinorIsland>().harborRemoved)
{
this.ended = true;
if (nameTuto_MinorIsland == "sous_ile_1")
{
Canvas endCanvasPrefab = Resources.Load<Canvas>("Prefab/Tuto/EndCanvas");
endCanvas = Instantiate(endCanvasPrefab);
Color color = endCanvas.GetComponentInChildren<SpriteRenderer>().color;
color.a = 0;
endCanvas.GetComponentInChildren<SpriteRenderer>().color = color;
}
}
}
if(ended && this.verticalTutoCompleted && !this.startEndAnimationFlag && this.nameTuto_MinorIsland == "sous_ile_1")
{
StartCoroutine(this.endFade());
this.startEndAnimationFlag = true;
}
/*------- open exchangeWindow after 1 sec --------*/
/*if (this.begun)
{
if ((Time.time - TouchTime > 1) && (Time.time - TouchTime < 1.5))
{
TouchTime = 0;
if (this.harborUpgraded && !this.exchangeResourceOpened)
{
displayPopup("Vous pouvez accéder à cette fenêtre à n'importe quel moment grâce à un appui long. Fermez la fenêtre.", 5);
this.createExchangeWindowTuto();
}
}
}*/
if (abort)
{
SceneSupervisor.Instance.loadLoadingScences();
}
}
示例9: 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;
}
示例10: Start
void Start()
{
menu = MenuScript.Instance;
chat = GameObject.Find("Chat").GetComponent<Canvas>();
text = chat.GetComponentInChildren<Text>();
dialogImage = chat.GetComponentInChildren<Image>();
journalScript = GetComponent<JournalScript>();
smallInput = GameManagerScript.SB.GetComponent<PlayerInputScript>();
bigInput = GameManagerScript.BB.GetComponent<PlayerInputScript>();
chat.enabled = false;
}
示例11: openShopWindow
/*
* This method opens the shop window from the shopUI Prefab (set in the inspector).
* It then sets all the visual components up, assigns them to variables and updates the shop.
*/
private void openShopWindow()
{
_player.GetComponent<PlayerController>().ignoreInput = true; // While the menu is open, ignore the player's movement
_shopUI = Object.Instantiate(shopUIPrefab) as Canvas;
_dropdown = _shopUI.GetComponentInChildren<Dropdown>();
// Add a listener to update the current item info when a new item is selected from the dropdown item list
_dropdown.onValueChanged.AddListener((int i) => {
this.updateCurrentItemInfo();
});
// Access the Text elements of the shop UI and make them blank for now
foreach(Text t in _shopUI.GetComponentsInChildren<Text>()){
if(t.name == "Quantity"){
_quantity = t;
_quantity.text = "";
}
else if(t.name == "Price"){
_price = t;
_price.text = "";
}
}
_slider = _shopUI.GetComponentInChildren<Slider>();
// We add a listener to the quantity slider
// When the amount of item requested is changed, the quantity text and total price update
_slider.onValueChanged.AddListener((float f) => {
if(_dropdown.value != 0){
_quantity.text = _slider.value + "";
_price.text = "$ " +((int)_slider.value) * _prices[_dropdownIDs[_dropdown.value]]; //Total price = Quantity * price of current item
}
});
_slider.gameObject.SetActive(false); // Hide the slider until we select an item from the dropdown
Button[] buttons = _shopUI.GetComponentsInChildren<Button>();
buttons[0].onClick.AddListener(() => { // Set the "<Back" button to close the shop
this.closeShopWindow();
});
buttons[1].onClick.AddListener (() =>{ // Set the "Buy" button to attempt to purchase the chosen quantity of the chosen item
this.buy();
});
updateDropdownList();
}