public void PlayStart(UnityAction onCountZero) { gameObject.SetActive (true); wasCountStart = true; onAnimationEnd = onCountZero; _animator.Play ("CountDown"); }
/// <summary> /// Removes the listener. /// </summary> /// <param name="listener">Listener.</param> public static void RemoveListener(UnityAction listener) { if (instance != null) { instance.mListeners.RemoveListener(listener); } }
private void MapActions() { UnityAction jumpAction = new UnityAction(() => { if (canJump) { ownerRigidBody.AddForce(this.transform.up * jumpForce, ForceMode.Impulse); canJump = false; } }); UnityAction moveForwardAction = new UnityAction(() => { ownerRigidBody.AddForce(this.transform.forward * movementVelocity, ForceMode.Acceleration); }); UnityAction moveBackAction = new UnityAction(() => { ownerRigidBody.AddForce(-this.transform.forward * movementVelocity, ForceMode.Acceleration); }); UnityAction moveLeftAction = new UnityAction(() => { ownerRigidBody.AddForce(-this.transform.right * movementVelocity, ForceMode.Acceleration); }); UnityAction moveRightAction = new UnityAction(() => { ownerRigidBody.AddForce(this.transform.right * movementVelocity, ForceMode.Acceleration); }); actionMap.Add(InputAction.Jump, jumpAction); actionMap.Add(InputAction.MoveBack, moveBackAction); actionMap.Add(InputAction.MoveForward, moveForwardAction); actionMap.Add(InputAction.MoveLeft, moveLeftAction); actionMap.Add(InputAction.MoveRight, moveRightAction); }
public static void AddClickToGameObject(GameObject gameObject, UnityAction action, EventTriggerType triggerType) { var eventTrigger = gameObject.AddComponent<EventTrigger>(); eventTrigger.triggers = new List<EventTrigger.Entry>(); AddEventTrigger(eventTrigger, action, triggerType); }
// button event function: A string, event 1, 2, and 3 public void Choice(string message, UnityAction button1Event, UnityAction button2Event, UnityAction exitEvent) { modalPanelObject.SetActive (true); Time.timeScale = 1; //pause button1Button.onClick.RemoveAllListeners(); button1Button.onClick.AddListener (button1Event); //button1Button.onClick.AddListener (ClosePanel); button2Button.onClick.RemoveAllListeners(); button2Button.onClick.AddListener (button2Event); //button2Button.onClick.AddListener (ClosePanel); exitButton.onClick.RemoveAllListeners(); exitButton.onClick.AddListener (exitEvent); exitButton.onClick.AddListener (ClosePanel); this.message.text = message; //this.iconImage.gameObject.SetActive (false); button1Button.gameObject.SetActive (true); button2Button.gameObject.SetActive (true); exitButton.gameObject.SetActive (true); }
public void CreatePlayer(string username,string playerName, string custom, UnityAction<bool> callback){ if (settings.saveLocal) { CreatePlayerInternalPrefs (playerName, custom, callback); } else { StartCoroutine (CreatePlayerInternal (username, playerName, custom, callback)); } }
private void CreatePlayerInternalPrefs(string playerName, string custom, UnityAction<bool> callback){ string newPlayer=playerName+","+custom+",1"; string allPlayers = PlayerPrefs.GetString (playersKey); string[] arr = allPlayers.Split('/'); if (arr.Length > 0) { for (int i = 0; i < arr.Length; i++) { string[] data = arr[i].Split(','); if(data.Length > 2){ string mName=data[0]; if(playerName == mName){ if(callback != null){ callback.Invoke(false); } return; } } } } if (callback != null) { callback.Invoke (true); } PlayerPrefs.SetString (playersKey,allPlayers + "/" + newPlayer); PlayerEventData eventData = new PlayerEventData (); eventData.playerName = playerName; eventData.level = 1; eventData.custom = custom; Execute("OnCreatePlayer",eventData); }
public static GameObject GenerateMenuButton(String prefabName, Transform parentTransform, Vector3 localScale, Vector3 localPosition, String buttonText , int textSize, UnityAction onClickCall, Color? buttonColor = null) { var button = Instantiate(Resources.Load(prefabName)) as GameObject; var rectTransform = button.transform as RectTransform; rectTransform.SetParent(parentTransform); rectTransform.localScale = localScale; rectTransform.localPosition = localPosition; var buttonComponent = button.GetComponent<Button>(); if (buttonComponent != null) { if (onClickCall != null) buttonComponent.onClick.AddListener(onClickCall); else buttonComponent.interactable = false; } if (String.IsNullOrEmpty(buttonText)) return button; var textComponent = button.GetComponentInChildren<Text>(); if (textComponent != null) { textComponent.text = buttonText; textComponent.fontSize = textSize; textComponent.font = Game.textFont; if (buttonColor.HasValue) textComponent.color = buttonColor.Value; } return button; }
public new void AddListener(UnityAction call) { int id = (call.Target as MonoBehaviour).gameObject.GetInstanceID (); m_Calls [id] = call; base.AddListener (call); }
public void AddListener(UnityAction<bool> action) { this.slider.onValueChanged.AddListener(delegate { action(this.Value); }); }
/// <summary> /// Initializes a new instance of the <see cref="EventButtonDetails"/> class. /// </summary> /// <param name="buttonTitle">The button title.</param> /// <param name="buttonAction">The button action.</param> public EventButtonDetails( string buttonTitle, UnityAction buttonAction) { this.buttonTitle = buttonTitle; this.buttonAction = buttonAction; }
internal void AddPersistentListener(UnityAction call, UnityEventCallState callState) { int persistentEventCount = base.GetPersistentEventCount(); base.AddPersistentListener(); this.RegisterPersistentListener(persistentEventCount, call); base.SetPersistentListenerState(persistentEventCount, callState); }
/// <summary> /// ダイアログを開く /// </summary> /// <param name="text">表示テキスト</param> /// <param name="buttonText1">ボタン1のテキスト</param> /// <param name="target">ボタンを押したときの呼ばれるコールバック</param> public void Open(string text, string buttonText1, UnityAction callbackOnClickButton1) { titleText.text = text; button1Text.text = buttonText1; this.OnClickButton1.AddListener(callbackOnClickButton1); Open(); }
public void Show(string question, string yesText, string noText, string cancelText, UnityAction yesEvent, UnityAction noEvent) { this.gameObject.SetActive (true); this.question.text = question; yesButton.onClick.RemoveAllListeners (); yesButton.onClick.AddListener (ClosePanel); if (yesEvent != null) yesButton.onClick.AddListener (yesEvent); yesButton.gameObject.SetActive (true); yesButton.gameObject.GetComponentInChildren<Text> ().text = yesText; noButton.onClick.RemoveAllListeners (); noButton.onClick.AddListener (ClosePanel); if (noEvent != null) noButton.onClick.AddListener (noEvent); noButton.gameObject.SetActive (true); noButton.gameObject.GetComponentInChildren<Text> ().text = noText; if (cancelText == null) { cancelButton.gameObject.SetActive (false); } else { cancelButton.gameObject.SetActive (true); cancelButton.onClick.RemoveAllListeners (); cancelButton.onClick.AddListener (ClosePanel); cancelButton.gameObject.GetComponentInChildren<Text> ().text = cancelText; } EventSystem.current.SetSelectedGameObject(yesButton.gameObject); }
public void BuyYinYanCommand() { // Show modal panel to confirm purchase buyAction = new UnityAction(PurchaseYinYan); string buyButtonText = "0.99$"; switch (yinYanButtonText.text) { case "0.99$": modalPanel.ShowModalWindow( confirmationString, "YinYan", "0.99$", buyAction, cancelAction); PurchaseYinYanVanity(); break; case "Activate Skin": LevelManager.manager.AnimationSkin = eAnimationSkin.YinYan; PurchaseYinYanVanity(); break; case "Deactivate Skin": LevelManager.manager.AnimationSkin = eAnimationSkin.Rotator; PurchaseYinYanVanity(); break; } }
//준비 void Awake() { modalpanel = ModalPanel.Instace (); reEventAction = new UnityAction (CallRestartFunc); maEventAction = new UnityAction (CallGomainFunc); }
/// <summary> /// Creates a blocker that covers the entire screen. /// </summary> /// <param name="onClosed">The callback which is called whenever the blocker is clicked and closed</param> /// <param name="sortingOrder">The SortingOrder for the blocker canvas, this value should be higher then any canvas that shouldn't receive input and lower then any canvas that should receive input</param> /// <param name="sortingLayerID">The layerID for the blocker canvas</param> public static void CreateBlocker(UnityAction onClosed, int sortingOrder, int sortingLayerID) { GameObject go = new GameObject("BlockerCanvas"); Canvas canvas = go.AddComponent<Canvas>(); go.AddComponent<GraphicRaycaster>(); canvas.renderMode = RenderMode.ScreenSpaceOverlay; canvas.sortingLayerID = sortingLayerID; canvas.sortingOrder = sortingOrder; GameObject blocker = new GameObject("Blocker"); RectTransform transform = blocker.AddComponent<RectTransform>(); transform.SetParent(go.transform, false); transform.anchorMin = Vector3.zero; transform.anchorMax = Vector3.one; transform.offsetMin = transform.offsetMax = Vector2.zero; Image image = blocker.AddComponent<Image>(); image.color = Color.clear; Button button = blocker.AddComponent<Button>(); button.onClick.AddListener(() => { UnityEngine.Object.Destroy(go); onClosed(); }); }
void Awake() { modalPanel = ModalPanel.Instance (); //Set actions AcceptAction = new UnityAction (OnYes); DenyAction = new UnityAction (OnNo); }
public static void StopListening(string eventName, UnityAction listener) { if (eventManager == null) return; UnityEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
void Start() { /* * */ OnBackButton = () => { Application.LoadLevel(0);}; CancleButton.onClick.AddListener(OnBackButton); //获取关卡 m_levels = LevelSystem.LoadLevels(); //动态生成关卡 int i = 0; foreach (Level level in m_levels) { GameObject prefab = (GameObject)Instantiate((Resources.Load("Level") as GameObject)); //数据绑定 DataBind(prefab, level); //设置父物体 prefab.transform.SetParent(GameObject.Find("Canvas/Background/LevelPanel").transform); // prefab.transform.localPosition = new Vector3(m_levels.Count/3*100+140, m_levels.Count%3*100-140, 0); prefab.GetComponent<RectTransform>().localPosition = new Vector3(i%3*100-100,-i/3*100+100, 0); i++; prefab.transform.localScale = Vector3.one; //将关卡信息传给关卡 prefab.GetComponent<LevelEvent>().level = level; prefab.name = level.Name; } }
public void ShowYesNoDialog(UnityAction yesMethod, string msg, string header) { btnYes.GetComponent<Button>().onClick.RemoveAllListeners(); btnYes.GetComponent<Button>().onClick.AddListener(yesMethod); yesNoDialogMessage.GetComponent<Text>().text = msg; dialogHeader.GetComponent<Text>().text = header; yesNoDialogBox.SetActive(true); }
/* Metodo para activar el panel(aviso) cuando se haya acertado en algun nivel pregunta = texto que saldra en el panel yesEvent= metodo (evento a ejecutar ) si se acepta aceptar= Boton para accion aceptar cancelar= Boton para accion cancelar bandera = booleano para modificar paneles informativos */ public void AvisoAcierto(string pregunta, UnityAction yesEvent, Button aceptar,Button cancelar, Button help) { //Activo el panel (por defecto desactivado) modalPanelO.SetActive(true); //Genero el texto que aparecera en el aviso TextUI.text = pregunta; //Desactivo cancelar cancelar.gameObject.SetActive(false); aceptar.gameObject.SetActive(false); //Activo botn help ( que hara de ok para este panel) help.gameObject.SetActive(true); /* * Remuevo y agrego los oyentes del boton cancelar. * LLama al evento de tipo(UnityAction) que sera * asignador a otro metodo en el script que le haya pasado * dicho evento.Es decir yesEvent=Metodo en el otro script */ aceptar.onClick.RemoveAllListeners(); if (yesEvent != null) { help.onClick.RemoveAllListeners(); help.onClick.AddListener(yesEvent); } //Cambio la imagen del boton aceptar help.GetComponentInChildren<Image>().sprite = ok; activo = true; }
internal void RegisterPersistentListener(int index, UnityAction call) { if (call == null) Debug.LogWarning((object) "Registering a Listener requires an action"); else this.RegisterPersistentListener(index, (object) (call.Target as UnityEngine.Object), call.Method); }
/// <summary> /// Open the MessageBox /// </summary> /// <param name="title">Title.</param> /// <param name="text">Text.</param> /// <param name="icon">Icon.</param> /// <param name="result">Result.</param> /// <param name="buttons">Buttons.</param> public virtual void Open(string title, string text, Sprite icon, UnityAction<string> result, params string[] buttons) { for (int i=0; i<buttonCache.Count; i++) { buttonCache[i].gameObject.SetActive(false); } if (!string.IsNullOrEmpty (title)) { this.title.text = title; this.title.gameObject.SetActive (true); } else { this.title.gameObject.SetActive(false); } this.text.text = text; if(icon != null){ this.icon.sprite = icon; this.icon.transform.parent.gameObject.SetActive(true); }else{ this.icon.transform.parent.gameObject.SetActive(false); } button.gameObject.SetActive (false); for (int i=0; i<buttons.Length; i++) { string caption=buttons[i]; AddButton(caption).onClick.AddListener(delegate() { result.Invoke(caption); Close(); }); } base.Open (); }
private GameObject CreateButton(Transform parent, Vector2 sizeDelta, Vector2 anchoredPosition, string message, UnityAction eventListner) { GameObject buttonObject = new GameObject("Button"); buttonObject.transform.SetParent(parent); buttonObject.layer = LayerUI; RectTransform trans = buttonObject.AddComponent<RectTransform>(); trans.SetPivotAndAnchors(new Vector2(0, 1)); SetSize(trans, sizeDelta); trans.anchoredPosition = anchoredPosition; CanvasRenderer renderer = buttonObject.AddComponent<CanvasRenderer>(); Image image = buttonObject.AddComponent<Image>(); image.color = Color.grey; Texture2D tex = Resources.Load<Texture2D>(("Elements_Air"); image.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)); Button button = buttonObject.AddComponent<Button>(); button.interactable = true; button.onClick.AddListener(eventListner); GameObject textObject = CreateText(buttonObject.transform, new Vector2(0, 0), new Vector2(50, 20), message, 14, "DataType"); return buttonObject; }
// A string, an image and three possible responses with text public void Choice( string speech, Sprite speakerImage, string response1Text, UnityAction response1Event,string response2Text, UnityAction response2Event,string response3Text, UnityAction response3Event) { modalPanelObject.SetActive (true); response1.onClick.RemoveAllListeners (); response1.onClick.AddListener (response1Event); response1.onClick.AddListener (ClosePanel); response2.onClick.RemoveAllListeners (); response2.onClick.AddListener (response2Event); response2.onClick.AddListener (ClosePanel); response3.onClick.RemoveAllListeners (); response3.onClick.AddListener (response3Event); response3.onClick.AddListener (ClosePanel); this.speakerSpeech.text = speech; this.speakerImage.sprite = speakerImage; this.response1.GetComponentInChildren<Text>().text = response1Text; this.response2.GetComponentInChildren<Text>().text = response2Text; this.response3.GetComponentInChildren<Text>().text = response3Text; this.speakerImage.gameObject.SetActive (true); this.response1.gameObject.SetActive (true); this.response2.gameObject.SetActive (true); this.response3.gameObject.SetActive (true); }
protected void AddBehaviour(UnityAction behaviour, UnityAction begin, UnityAction end) { ValidateBeginAndEndNames (behaviour, begin, end); string stateName = ValidateKey (behaviour.Method.Name); Behaviour b = new Behaviour (stateName, behaviour, begin, end); AddBehaviour (stateName, b); }
// http://docs.unity3d.com/Manual/script-Button.html public static void onClick (Button button, UnityAction _onClick) { button.interactable = true; if (_onClick != null) { button.onClick.AddListener (_onClick); } }
public static void Cancel() { callback = null; flag = true; cancelObject.gameObject.SetActive (false); cancelObject = null; }
//Metodo para llamar al panel recibe el texto , el event que seria el metodo a ejecutar en caso de aceptar //El boton aceptar y el boton cancelar public void Elejir(string pregunta, UnityAction yesEvent, Button aceptar, Button cancelar, bool bandera, Button help = null) { ModalPanelObjeto.SetActive(true);//Activo el panel porque inicialmente tiene que estar desactivado para que no se muestre en la escena TextUI.text = pregunta;//Le asigno al texto de la ui la pregunta que le mando al llamar a este metodo if (help != null && help.IsActive()) help.gameObject.SetActive(false); //Asigno los eventos al boton cancelar para que cierre el panel este lo hago aqui porque el simple //Pero los eventos para el metodo de aceptar los hago en el otro script porque tengo que usar variables de ese script cancelar.onClick.RemoveAllListeners(); cancelar.onClick.AddListener(CerrarPanel); //Ahora para los eventos de aceptar paso el UnityAction y al llamarlo le asigno un metodo en el otro script //O sea yesEvent=Metodo en el otro script aceptar.onClick.RemoveAllListeners(); if (yesEvent != null) { aceptar.onClick.RemoveAllListeners(); aceptar.onClick.AddListener(yesEvent); } aceptar.gameObject.SetActive(true); aceptar.GetComponentInChildren<Image>().sprite = si; if (bandera) //Esto es para los paneles informativos dejarle un solo boton { cancelar.gameObject.SetActive(false); aceptar.GetComponentInChildren<Image>().sprite = ok; } else { cancelar.gameObject.SetActive(true); } activo = true; }
/// <summary> /// Construct a new timer. /// </summary> /// <param name="duration">The amount of time the timer should run.</param> /// <param name="onFinished">Action invoked when the timer is finished.</param> public Timer(float duration, UnityAction onFinished) : this(duration) { Finished.AddListener(onFinished); }
public IEnumerator MoveWorldFrom(Transform dealer, Transform cardHand, float dur, float wait, UnityAction callback = null) { yield return(new WaitForSeconds(wait)); img_card.enabled = true; float x = transform.localPosition.x; float y = transform.localPosition.y; transform.SetParent(dealer); transform.localScale = Vector2.zero; transform.localPosition = Vector2.zero; transform.SetParent(cardHand); Vector3 vt = new Vector3(x, y, 0f); SetVisible(true); transform.localScale = Vector3.one; transform.DOScale(1, dur); transform.DOLocalMove(vt, dur).OnComplete(delegate { if (callback != null) { callback(); } }); }
public IMCWait(Guid id, float receiveUntil, UnityAction<IMCMessage> onReceive, UnityAction onTimeout) { ID = id; ReceiveUntil = receiveUntil; OnReceive = onReceive; OnTimeout = onTimeout; }
/// <summary> /// Calls a remote function without payload, expecting a return value of a specific type /// </summary> /// <typeparam name="R">The type of the return value of the called function</typeparam> /// <param name="target">The target port to send the message to</param> /// <param name="name">The name of the remote function</param> /// <param name="payload">The payload to pass to the function</param> /// <param name="timeout">The amount of time, in seconds, to wait for a response</param> /// <param name="callback">The callback to call upon receiving a response</param> /// <param name="error">The callback to call upon encountering errors</param> public void RPC<R>(string target, string name, float timeout, UnityAction<R> callback, UnityAction<Exception> error) { try { var message = IMCMessage.CreateRequest(this.name, name); SendIMCMessage( target, message, timeout, (msg) => { callback?.Invoke(msg.ParsePayload<R>()); }, () => { error.Invoke(TimeoutException.Instance); }); } catch (Exception ex) { error?.Invoke(ex); } }
/// <summary> /// Calls a remote function using the given payload, expecting no return value /// </summary> /// <typeparam name="P">The type of the payload to pass to the function</typeparam> /// <param name="target">The target port to send the message to</param> /// <param name="name">The name of the remote function</param> /// <param name="payload">The payload to pass to the function</param> /// <param name="timeout">The amount of time, in seconds, to wait for a response</param> /// <param name="callback">The callback to call upon receiving a response</param> /// <param name="error">The callback to call upon encountering errors public void RPC<P>(string target, string name, P payload, float timeout, UnityAction callback, UnityAction<Exception> error) { try { var message = IMCMessage.CreateRequest(this.name, name, JsonConvert.SerializeObject(payload)); SendIMCMessage( target, message, timeout, (msg) => { callback?.Invoke(); }, () => { error.Invoke(TimeoutException.Instance); }); } catch (Exception ex) { error?.Invoke(ex); } }
private void SendIMCMessage(string _target, IMCMessage message, float timeout, UnityAction<IMCMessage> onReceive, UnityAction onTimeout) { var target = GetIMCPort(_target); if (target == null) throw new SendMessageException("Target not set"); if (!target.gameObject.activeInHierarchy) throw new SendMessageException($"Receiving GameObject \"{target.name}\" is inactive"); if (onReceive != null && onTimeout != null) { pendingResponses.Add(new IMCWait( message.ID, Time.time + timeout, onReceive, onTimeout) ); } target.SendMessage(nameof(ReceiveMessage), message.ToObjects()); }
public void AddLeafEvent(UnityAction <string> callFun) { clickFun = callFun; }
public override AssetAsyncLoad LoadAssetAsync(string assetName, UnityAction <Object> loadedCallback, AssetLoadPriority priority = AssetLoadPriority.Normal) { return(LoadAssetAsync(assetName, loadedCallback, null, priority)); }
/// <summary> /// 初始化按键 /// </summary> /// <param name="name"></param> public virtual void Init(string name, UnityAction click = null) { transform.Find("Name").GetComponent <Text>().text = name; clickCallBack = click; }
public override AssetAsyncLoad LoadAssetAsync(string assetName, UnityAction <Object> loadedCallback, UnityAction <float> progressCallback, AssetLoadPriority priority = AssetLoadPriority.Normal) { if (m_CurrentLoadTask != null) { if (m_AssetLoadList[(int)priority].ContainsKey(assetName)) { var loadTask = m_AssetLoadList[(int)priority][assetName]; loadTask.AssetName = assetName; var asyncLoad = new AssetAsyncLoad(assetName); loadTask.AddCallback(asyncLoad, loadedCallback, progressCallback); return(asyncLoad); } else { var loadTask = AssetLoadTask.GetAssetLoadTask(); loadTask.AssetName = assetName; var asyncLoad = new AssetAsyncLoad(assetName); loadTask.AddCallback(asyncLoad, loadedCallback, progressCallback); m_AssetLoadList[(int)priority].Add(assetName, loadTask); return(asyncLoad); } } else { var loadTask = AssetLoadTask.GetAssetLoadTask(); loadTask.AssetName = assetName; var asyncLoad = new AssetAsyncLoad(assetName); loadTask.AddCallback(asyncLoad, loadedCallback, progressCallback); m_CurrentLoadTask = loadTask; StartLoadAsset(); return(asyncLoad); } }
protected void RegisterButton(string btnName, UnityAction func) { transform.FindDownNode(btnName).GetComponent <Button>().onClick.AddListener(func); }
/// <summary> /// Transform扩展添加 EventTrigger 事件 /// </summary> /// <param name="trs"></param> /// <param name="eventID">事件类型</param> /// <param name="callback">事件回调</param> public static void AddTrsEntryTriggerEvent(this Transform trs, EventTriggerType eventID, UnityAction <BaseEventData> callback) { EventTrigger trigger = null; trigger = trs.GetComponent <EventTrigger>(); if (trigger == null) { trigger = trs.gameObject.AddComponent <EventTrigger>(); } var entry = trigger.triggers.Find((_entry) => { return(_entry.eventID == eventID); }); if (entry == null) { entry = new EventTrigger.Entry(); entry.eventID = eventID; trigger.triggers.Add(entry); } entry.callback.AddListener(callback); }
public static void RemoveListener(UnityAction <LootResult> callback) { EVENT_LOOT.RemoveListener(callback); }
private IEnumerator delayedAction(UnityAction action, int delay) { yield return(new WaitForSeconds(delay)); action.Invoke(); }
/// <summary> /// 显示面板 /// </summary> /// <typeparam name="T">面板脚本类型</typeparam> /// <param name="panelName">面板名</param> /// <param name="layer">显示在哪一层</param> /// <param name="callBack">当面板预设体创建成功后 你想做的事</param> public void OpenPanel <T>(string panelName, E_UI_Layer layer = E_UI_Layer.Mid, UnityAction <T> callBack = null) where T : BasePanel { if (panelDic.ContainsKey(panelName)) { //处理面板创建完成后的逻辑 if (callBack != null) { callBack(panelDic[panelName] as T); } } ResMgr.GetInstance().LoadAsync <GameObject>(AssetUtility.GetUIAsset(panelName), (obj) => { //把他作为Canvas的子对象 //并且 要设置它的相对位置 //找到父对象 你到底显示再哪一层 Transform father = bot; switch (layer) { case E_UI_Layer.Mid: father = mid; break; case E_UI_Layer.Top: father = top; break; case E_UI_Layer.System: father = system; break; } //设置父对象 obj.transform.SetParent(father); obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; (obj.transform as RectTransform).offsetMax = Vector2.zero; (obj.transform as RectTransform).offsetMin = Vector2.zero; //得到预设体身上的面板脚本 T panel = obj.GetComponent <T>(); //处理面板创建后的逻辑 if (callBack != null) { callBack(panel); } //把面板存起来 panelDic.Add(panelName, panel); }); }
protected void UnRegisterEvent(string eventName, UnityAction <ScriptEventArgs> func) { EventMgr.GetInstance().UnregisterEvent(eventName, func); }
public void Init(string titleText, UnityAction <string, string, string, string> registAction, UnityAction cancelAction) { TitleText.text = titleText; OkButton.onClick.AddListener(() => registAction?.Invoke(IDForm.text, PasswordForm.text, NicknameForm.text, PhoneNumberForm.text)); CancelButton.onClick.AddListener(() => cancelAction?.Invoke()); }
public void RemoveOnTakeDamage(UnityAction <float, GameplayStatics.DamageType> action) { m_OnTakeDamage.RemoveListener(action); }
/// <summary> /// Adds the listener to the Event Manager /// </summary> /// <param name="listener"></param> public void MaxEnergyListener(UnityAction listener) { maxEnergyEvent.AddListener(listener); }
public void PlayOutro(UnityAction animationComplete) { textPanel.DOLocalMoveY(500f, 1f).SetEase(Ease.InSine); playButton.DOLocalMoveY(-500f, 1f).SetEase(Ease.InSine).OnComplete(() => { animationComplete?.Invoke(); }); }
public static SteamVR_Events.Action <TeleportMarkerBase> PlayerPreAction(UnityAction <TeleportMarkerBase> action) { return(new SteamVR_Events.Action <TeleportMarkerBase>(PlayerPre, action)); }
public void Initialize(string title, List <SelectOptionDialogOption> options, UnityAction okAction, bool canCancel = false, UnityAction cancelAction = null, string okLabel = "OK", string cancelLabel = "Cancel") { baseTitle = title; base.Initialize(baseTitle, okAction, canCancel, cancelAction, okLabel, cancelLabel); this.options = options; RefreshDisplayedOption(); }
public void New(float seconds, int loopTimes, UnityAction breakAction, UnityAction doneAction, UnityAction cancelAction, string actionName = null, bool displayCancel = false) { if (seconds <= 0 || loopTimes < 0) { return; } if (progressCoroutine != null) { StopCoroutine(progressCoroutine); progressCoroutine = null; } onDone = doneAction; onCancel = cancelAction; breakCondition = null; this.breakAction = breakAction; targetTime = seconds; isProgressing = true; this.loopTimes = loopTimes; if (actionText) { if (string.IsNullOrEmpty(actionName)) { ZetanUtility.SetActive(actionText.gameObject, false); } else { actionText.text = actionName; ZetanUtility.SetActive(actionText.gameObject, true); } } ZetanUtility.SetActive(bar, true); ZetanUtility.SetActive(cancel, displayCancel); barCanvas.sortingOrder = WindowsManager.Instance.TopOrder + 1; breakCondition = null; progressCoroutine = StartCoroutine(Progress()); }
/// <summary> /// 切换场景 异步 /// </summary> /// <param name="name"></param> /// <param name="action"></param> public void LoadSceneAsyn(string name, UnityAction action) { MonoMgr.getInst().StartCoroutine(ReallyLoadSceneAsyn(name, action)); }
public void ListenToHintCalcStart(UnityAction action) { Debug.Log("HintCalcStart Listener Added"); HintCalcStart.AddListener(action); }
public static SteamVR_Events.Action <float> ChangeSceneAction(UnityAction <float> action) { return(new SteamVR_Events.Action <float>(ChangeScene, action)); }
public void ListenToDisconnectAIHard(UnityAction action) { Debug.Log("DisconnectAIHard Listener Added"); DisconnectAIHard.AddListener(action); }
public void ListenToHintCalcEnd(UnityAction action) { Debug.Log("HintCalcEnd Listener Added"); HintCalcEnd.AddListener(action); }
public void ListenToDisconnectAIEasy(UnityAction action) { Debug.Log("DisconnectAIEasy Listener Added"); DisconnectAIEasy.AddListener(action); }
public void ListenToMultiplayerSelected(UnityAction action) { Debug.Log("MultiplayerSelected Listener Added"); MultiplayerSelected.AddListener(action); }