本文整理汇总了C#中UnityAction类的典型用法代码示例。如果您正苦于以下问题:C# UnityAction类的具体用法?C# UnityAction怎么用?C# UnityAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnityAction类属于命名空间,在下文中一共展示了UnityAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Show
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);
}
开发者ID:rodsordi,项目名称:Gude,代码行数:30,代码来源:QuestionDialog.cs
示例17: Elejir
//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;
}
开发者ID:zeldax54,项目名称:jregame,代码行数:36,代码来源:ModalPanel.cs
示例18: AddPersistentListener
internal void AddPersistentListener(UnityAction call, UnityEventCallState callState)
{
int persistentEventCount = base.GetPersistentEventCount();
base.AddPersistentListener();
this.RegisterPersistentListener(persistentEventCount, call);
base.SetPersistentListenerState(persistentEventCount, callState);
}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:7,代码来源:UnityEvent.cs
示例19: AddListener
public void AddListener(UnityAction<bool> action)
{
this.slider.onValueChanged.AddListener(delegate
{
action(this.Value);
});
}
开发者ID:CanPayU,项目名称:SuperSwungBall,代码行数:7,代码来源:SwitchController.cs
示例20: ShowYesNoDialog
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);
}
开发者ID:oguretsss,项目名称:par,代码行数:7,代码来源:WorldMapCanvas.cs
注:本文中的UnityAction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论