当前位置: 首页>>代码示例>>C#>>正文


C# UnityAction类代码示例

本文整理汇总了C#中UnityAction的典型用法代码示例。如果您正苦于以下问题:C# UnityAction类的具体用法?C# UnityAction怎么用?C# UnityAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UnityAction类属于命名空间,在下文中一共展示了UnityAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddClickToGameObject

        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);
        }
开发者ID:mengtest,项目名称:UnityRPG,代码行数:7,代码来源:UIHelper.cs

示例2: CreatePlayerInternalPrefs

	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);
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:31,代码来源:PlayerSystem.cs

示例3: Choice

    // 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);
    }
开发者ID:DeSanguinist,项目名称:CobbleGame,代码行数:26,代码来源:ModalPanel.cs

示例4: EventButtonDetails

 /// <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;
 }
开发者ID:JonJam,项目名称:marveluniverse,代码行数:12,代码来源:EventButtonDetails.cs

示例5: AddListener

        public new void AddListener(UnityAction call)
        {
            int id = (call.Target as MonoBehaviour).gameObject.GetInstanceID ();
            m_Calls [id] = call;

            base.AddListener (call);
        }
开发者ID:osmanzeki,项目名称:bmachine,代码行数:7,代码来源:UnityEventEx.cs

示例6: BuyYinYanCommand

    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;
        }
    }
开发者ID:YuvalFeldman,项目名称:Rotator,代码行数:28,代码来源:StorePresenter.cs

示例7: Open

		/// <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();
		}
开发者ID:OsamaRazaAnsari,项目名称:2DDressUpGame,代码行数:13,代码来源:SystemUiDialog1Button.cs

示例8: RegisterPersistentListener

 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);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:7,代码来源:UnityEvent.cs

示例9: onClick

	// 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);
		}
	}
开发者ID:timpala-com,项目名称:unity3d-toolkit,代码行数:8,代码来源:SGUIButton.cs

示例10: Open

        /// <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 ();
        }
开发者ID:gloowa,项目名称:mstest,代码行数:38,代码来源:MessageBox.cs

示例11: CreateButton

        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;
        }
开发者ID:TPSAncient,项目名称:TurnBasedStrategy,代码行数:28,代码来源:UICityView.cs

示例12: AddBehaviour

 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);
 }
开发者ID:rodsordi,项目名称:Gude,代码行数:7,代码来源:StateBehaviour.cs

示例13: Choice

    // 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);
    }
开发者ID:Beyondourken,项目名称:PrinceOfLilies,代码行数:28,代码来源:ModalPanel.cs

示例14: CreateBlocker

        /// <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();
            });
        }
开发者ID:yoyo2004cn,项目名称:VWCarFactory,代码行数:34,代码来源:InputBlocker.cs

示例15: panel

    /*
    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;
    }
开发者ID:88dre88,项目名称:ProyectoU,代码行数:44,代码来源:ModalPanel.cs


注:本文中的UnityAction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。