void Awake() { _canvas = GetComponentInChildren <Canvas>(); _energyInitialWidth = EnergyBar.rectTransform.rect.width / _canvas.scaleFactor; _undoImage = UndoButton.GetComponentInChildren <UIButtonController>(); }
public void ShowDialogueBox(string[] contents, string title = "") { if (title != "") { title = title.ToUpper(); } Player.instance.IsCurrentlyBusy = true; gameObject.SetActive(true); if (UIBC == null) { UIBC = NextButton.GetComponent <UIButtonController> (); } dialogue.Clear(); foreach (string log in contents) { if (log.Length > 1024) { Debug.LogWarning("UIDialogueController::ShowDialogueBox -- One of " + title + "'s contents is more than 1,024 characters"); } dialogue.Enqueue(log); } // TODO: These need to probably get their data from Localisation, you'd probably give in LocalisationIDs. listOfTextElements [0].text = title; DisplayNextSentence(); }
public static void AddButton(UIButtonController _button) //кнопка { if (_button.type == TypeButton.None) { return; } lButton.Add(_button); }
public bool RemoveButtonController(UIButtonController buttonController) { if (buttonControllers.Contains(buttonController)) { buttonControllers.Remove(buttonController); return(true); } return(false); }
public bool AddButtonController(UIButtonController buttonController) { if (buttonControllers.Contains(buttonController)) { return(false); } buttonControllers.Add(buttonController); return(true); }
/* sets the MVC relationships */ public void createMVC(UIButtonModel m, UIButtonView v, UIButtonController c) { Model = m; View = v; Controller = c; Model.setElement(this); View.setElement(this); Controller.setElement(this); }
void Update() { RaycastHit hit; UIButtonController buttonController = null; #if UNITY_EDITOR for (int i = 0; i < 3; ++i) { if (Input.GetMouseButtonDown(i)) { if (UICamera.Raycast(Input.mousePosition, out hit)) { buttonController = hit.collider.GetComponent <UIButtonController>(); if (buttonController != null) { buttonController.Press(); } } } else if (Input.GetMouseButton(i)) { if (UICamera.Raycast(Input.mousePosition, out hit)) { buttonController = hit.collider.GetComponent <UIButtonController>(); if (buttonController != null) { buttonController.Holding(); } } } } #else foreach (Touch touch in Input.touches) { if (UICamera.Raycast(touch.position, out hit)) { buttonController = hit.collider.GetComponent <UIButtonController>(); if (buttonController != null) { switch (touch.phase) { case TouchPhase.Began: buttonController.Press(); break; case TouchPhase.Moved: case TouchPhase.Stationary: buttonController.Holding(); break; } } } } #endif }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else if (instance != null) { Destroy(gameObject); } }
void Start() { if (prefabUIObject != null) { uiObject = Instantiate(prefabUIObject) as UIObject; uiObject.transform.parent = UIRoot2D.Get().game.transform; uiObject.transform.localPosition = transform.position; uiObject.transform.localRotation = transform.rotation; uiObject.transform.localScale = Vector3.one; buttonController = uiObject.GetComponent <UIButtonController>(); } Start_(); }
void OnSubBtnClick(UIButtonController controller) { if (controller != null) { var animName = controller.btnName; Debug.LogError("按钮点击:" + animName + " " + animationController[animName]); if (animationController != null) { if (!animSet.Contains(animName)) { animationController[animName] = AssetsHelper.LoadAssetAtPath(string.Format(@"Assets\GameAssets\Models\aisi\Anim\aisi@aisi@{0}.anim", animName), typeof(AnimationClip)) as AnimationClip; Debug.LogError(string.Format("动作为空 {0}", animName)); animSet.Add(animName); } playerAnimator.Play(animName, 0); } } }
public override void instantiateElement(Vector3 startPos, Vector3 endPos) { UIButtonModel newModel = new UIButtonModel(); // instantiate GameObject GameObject newObject = Singletons.Instantiator.instantiateObject(Type); // get the View from GameObject UIButtonView newView = newObject.transform.GetComponent <UIButtonView>(); // assign MVC so everyone knows each other UIButtonController newController = new UIButtonController(); this.createMVC(newModel, newView, newController); // update Model values - must be done after MVC is created newModel.Position = endPos; newModel.initModel(); }
void Start() { this.controller = this.gameObject.GetComponent <CharacterController>(); this.spriteRenderer = this.gameObject.GetComponent <SpriteRenderer>(); this.animator = this.gameObject.GetComponent <Animator>(); // Alcune caratteristiche peculiari del secondo giocatore if (this.playerNo == 2) { this.zPos = -zPos; this.direction = Direction.Left; } this.gameObject.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, this.zPos); // Le dimensioni del personaggio this.xSize = this.controller.bounds.extents.x * 2; this.ySize = this.controller.bounds.extents.y * 2; // Trova le componenti della UI associate ai tasti leftMovementBtn = GameObject.Find("P" + this.playerNo + "LeftBtn").GetComponent <UIButtonController>(); rightMovementBtn = GameObject.Find("P" + this.playerNo + "RightBtn").GetComponent <UIButtonController>(); jumpBtn = GameObject.Find("P" + this.playerNo + "JumpBtn").GetComponent <UIButtonController>(); // Setta le impostazioni audio audioSource = GetComponent <AudioSource>(); }