本文整理汇总了C#中Button.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Button.GetComponent方法的具体用法?C# Button.GetComponent怎么用?C# Button.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button
的用法示例。
在下文中一共展示了Button.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
//void Start () {
//}
void Start()
{
icon = PlayerUIMgr.instance.AddHunterIcon();
icon.GetComponent<BoundObject>().SetBoundTranform(this.transform);
//icon.onClick.AddListener(this.GetComponent<NvigationGame>().Select);
hunter_nav = this.GetComponent<NvigationGame>();
name_text = PlayerUIMgr.instance.AddText();
name_text.GetComponent<BoundObject>().SetBoundTranform(this.transform);
name_text.GetComponent<BoundObject>().SetGap(new Vector2(0,20));
hunter_name_ui = HunterListPanel.instance.AddHunterName("hunter1");
hunter_name_ui.hunter = this;
SetName("hunter1");
icon.GetComponent<HunterUI>().hunter = this;
floor_mask = 1 << 8 + 1 << 9 + 1 << 10;
my_agent = this.transform.parent.GetComponent<NavMeshAgent>();
//追跡フラッグをoff
target = null;
}
示例2: CurveHandle
/// <summary>
/// </summary>
/// <param name="buttonTemplate"> </param>
/// <param name="lineTemplate"> </param>
/// <param name="pos"> </param>
/// <param name="prevComponent"> </param>
/// <param name="nextComponent"> </param>
public CurveHandle(ButtonGenerator buttonTemplate, LineGenerator lineTemplate, Vector2 pos, Vector2 prevComponent, Vector2 nextComponent)
{
buttonTemplate = new ButtonGenerator("HullEditorHandle.json");
buttonTemplate.Identifier = (int) HandleType.Center;
buttonTemplate.X = pos.X;
buttonTemplate.Y = pos.Y;
_centerButton = buttonTemplate.GenerateButton();
_centerButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
_centerButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;
buttonTemplate.Identifier = (int) HandleType.Prev;
buttonTemplate.X = prevComponent.X + pos.X;
buttonTemplate.Y = prevComponent.Y + pos.Y;
_prevButton = buttonTemplate.GenerateButton();
_prevButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
_prevButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;
buttonTemplate.Identifier = (int) HandleType.Next;
buttonTemplate.X = nextComponent.X + pos.X;
buttonTemplate.Y = nextComponent.Y + pos.Y;
_nextButton = buttonTemplate.GenerateButton();
_nextButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
_nextButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;
_prevLine = lineTemplate.GenerateLine();
_nextLine = lineTemplate.GenerateLine();
_prevLine.OriginPoint = _centerButton.CentPosition;
_prevLine.DestPoint = _prevButton.CentPosition;
_nextLine.OriginPoint = _centerButton.CentPosition;
_nextLine.DestPoint = _nextButton.CentPosition;
_nextButton.GetComponent<FadeComponent>().ForceFadeout();
_prevButton.GetComponent<FadeComponent>().ForceFadeout();
_centerButton.GetComponent<FadeComponent>().ForceFadeout();
_prevLine.GetComponent<FadeComponent>().ForceFadeout();
_nextLine.GetComponent<FadeComponent>().ForceFadeout();
_nextButton.GetComponent<FadeComponent>().ForceFadeout();
_prevButton.GetComponent<FadeComponent>().ForceFadeout();
_centerButton.GetComponent<FadeComponent>().ForceFadeout();
_prevLine.GetComponent<FadeComponent>().ForceFadeout();
_nextLine.GetComponent<FadeComponent>().ForceFadeout();
InterlinkButtonEvents();
}
示例3: SelectWeapon
public void SelectWeapon(Button button)
{
var buttonType = button.GetComponent<WeaponButton>().WeaponType;
var model = _weaponModels.First(w => w.Type == buttonType);
if (_playerNetwork.GetUserModel().Money < model.Cost)
{
Debug.Log("Not Enough Cash!");
return;
}
// Update actual weapon and money values
if (_currentWeapon.Type == model.Type) {
_weapon.UpdateAmmo(_currentWeapon.Ammo);
} else {
_currentWeapon = model;
_weapon.UpdateWeapon(_currentWeapon.Ammo, _currentWeapon.Damage, _currentWeapon.FireRate);
}
// Update user model
_teamsController.UpdateUserModelForAll(_playerNetwork.GetUserModel().Uid, UserModelField.MoneyIncrement, _currentWeapon.Cost * -1);
_teamsController.UpdateUserModelForAll(ServerData.serverInfo.userData.UID, UserModelField.Weapon, (int) buttonType);
//Update UI
UpdateWeaponUi();
PlayerCurrentWeapon.GetComponentsInChildren<Image>().First(x => x.name == "Image").sprite = _currentWeapon.Sprite;
PlayerCurrentWeapon.GetComponentsInChildren<Text>().First(x => x.name == "Name").text = _currentWeapon.Name;
PlayerCurrentWeapon.GetComponentsInChildren<Text>().First(x => x.name == "Ammo").text = _weapon.GetAmmo().ToString();
_hudController.AmmoText.text = _weapon.GetAmmo().ToString();
}
示例4: OnButtonPressed
public void OnButtonPressed(Button btn)
{
Debug.Log ("in OnButtonPressed ebm");
if (TurnManager.Pturn)
{
Vector2 btnPos = btn.GetComponent<ButtonInfo> ().position;
//Debug.Log ("vector x " + btnPos.x + "vector y " + btnPos.y);
//checking if boat structure is not complete yet and if it's the player's turn to attack
if(GetAttackResult(btnPos)!=-1)
{
//move successful
//ship exits
//ship loc marked as hit
//Debug.Log ("attack success");
all_buttons = this.GetComponentsInChildren<Button> ();
foreach (Button b in all_buttons) {
if ((b.GetComponent<ButtonInfo> ().position.x == btnPos.x) &&
(b.GetComponent<ButtonInfo> ().position.y == btnPos.y)) {
//checking if location has been already marked as missed or hit
if ((b.image.color.Equals (Color.black) == false) && (b.image.color.Equals (Color.red) == false)) {
b.image.color = new Color (Color.red.r, Color.red.g, Color.red.b, 1f);
hit_Counter++;
if (hit_Counter == SgameInfo.max_number_of_hits)
{
TurnManager.Pwon = true;
//Debug.Log ("game over - player won");
//winner code - 1 - player won
TurnManager.RestartLevel(1);
}
//Debug.Log("player's turn complete - change turn to PC");
TurnManager.EndTurn(false, true);
}
}
}
} else {
//get button loc from vector and color grey - no ship
//Debug.Log ("attack failed");
all_buttons = this.GetComponentsInChildren<Button> ();
foreach (Button b in all_buttons) {
if ((b.GetComponent<ButtonInfo> ().position.x == btnPos.x) &&
(b.GetComponent<ButtonInfo> ().position.y == btnPos.y)) {
//checking if location has been already marked as HIT or ship loc marked
if ((b.image.color.Equals (Color.black) == false) && (b.image.color.Equals (Color.red) == false)) {
b.image.color = new Color (Color.black.r, Color.black.g, Color.black.b, 1f);
}
//Debug.Log("player's turn complete - change turn to PC");
TurnManager.EndTurn(false, true);
}
}
}
}
}
示例5: Start
void Start()
{
cardText = gameObject.GetComponentInChildren<Text>();
cardImage = gameObject.GetComponentInChildren<Image>();
cardButton = gameObject.GetComponentInChildren<Button>();
cardButton.onClick.AddListener(() => HandleCardClicked());
matchController = GameObject.FindObjectOfType<MatchController>();
defaultCardBackground = cardButton.GetComponent<Image>().sprite;
}
示例6: Start
// Use this for initialization
void Start () {
PauseMenu = PauseMenu.GetComponent<Canvas> ();
resumeText = resumeText.GetComponent<Button> ();
exitText = exitText.GetComponent<Button> ();
restartText = exitText.GetComponent<Button> ();
controlsText= controlsText.GetComponent<Button> ();
exitControlsText = exitControlsText.GetComponent<Button> ();
PauseMenu.enabled = false;
ControlsImage.enabled = false;
//exitControlsText.enabled = false;
}
示例7: Start
void Start()
{
AudioSource[] temp = GetComponents<AudioSource> ();
foreach (AudioSource t in temp) {
if(t.clip.name == "OnHoverSound"){
OnHoverSound = t;
}
}
b = gameObject.GetComponent<Button> ();
b.GetComponent<Button>().onClick.AddListener(() => SoundManager.instance.PlayClickSound());
}
示例8: Start
// Use this for initialization
void Start () {
GameOverCanvas = GameOverCanvas.GetComponent<Canvas> ();
exitText = exitText.GetComponent<Button> ();
restartText = exitText.GetComponent<Button> ();
GameOverCanvas.enabled = false;
}
示例9: Start
// Use this for initialization
void Start()
{
playerdead = playerdead.GetComponent<Canvas>();
restart = quit.GetComponent<Button> ();
quit = restart.GetComponent<Button> ();
player = player.GetComponent<Text> ();
quitmenu.enabled = false;
restart.enabled = true;
quit.enabled = true;
player.enabled = true;
}
示例10: SetCharacterSelection
public void SetCharacterSelection(Button button)
{
GameObject.Find("Triceratot").GetComponent<Image>().color = Color.red;
GameObject.Find("Squarebeast").GetComponent<Image>().color = Color.red;
button.GetComponent<Image>().color = Color.white;
if (button.name.Equals("Triceratot"))
playerCharacter = "triceratops";
if (button.name.Equals("Squarebeast"))
playerCharacter = "monster";
}
示例11: ComponentCtor
public void ComponentCtor(Button owner){
_owner = owner;
//event stuff
if (owner.DoesComponentExist<DraggableComponent>()){
var dcomponent = _owner.GetComponent<DraggableComponent>();
dcomponent.DragMovementDispatcher += OnOwnerDrag;
}
//create sprite
_highlightSprite = new Sprite2D(_owner.RenderTarget, _highlightTexture, (int) _owner.X, (int) _owner.Y, (int) _owner.Width, (int) _owner.Height, 0);
}
示例12: playScaleAnimation
public void playScaleAnimation(Button button,string type)
{
for (int i = 0; i < buttons.Length; i++)
{
if (button == buttons[i])
{
if (button.image.sprite == buttonSprites[i * 2])
{
Animator anim = button.GetComponent<Animator>();
anim.SetBool(type, true);
}
}
}
}
示例13: Update
// Update is called once per frame
void Update () {
if(!_video.isPlaying)
{
if(_buttonBegin)
{
_buttonBegin = Button.FindObjectOfType<Button>();
_buttonBegin.GetComponent<Animator>().SetBool("ShowButton", true);
}
}
//if (Input.GetMouseButtonUp(0))
//{
// Application.LoadLevel(1);
//}
}
示例14: InAcitaveTab
private void InAcitaveTab(Button button)
{
RectTransform Button_rect = button.GetComponent<RectTransform>();
Color SelectedColor;
Color.TryParseHexString("E4E4E4FF", out SelectedColor);
button.image.color = SelectedColor;
Button_rect.sizeDelta = new Vector2(Button_rect.sizeDelta.x, Button_rect.sizeDelta.y - SelectedTabSize);
Button_rect.transform.position = new Vector3(Button_rect.transform.position.x,
Button_rect.transform.position.y - SelectedTabSize / 2,
Button_rect.transform.position.z);
}
示例15: NewGame
/**
* Prepares a text area and an accept button to create a new game
*/
public void NewGame()
{
if (character == null) {
character = Instantiate (text) as InputField;
save = Instantiate (apply) as Button;
character.transform.SetParent(canvas.transform);
save.transform.SetParent(canvas.transform);
character.GetComponent<RectTransform>().localPosition = new Vector2(-50, -200);
save.GetComponent<RectTransform>().localPosition = new Vector2(100, -200);
save.onClick.AddListener(() => StartGame());
save.onClick.AddListener(() => GameControl.control.LoadNextScreen("Overworld"));
}
}