Browse Source

Merge pull request #170 from FungusGames/text-input-event-handlers

Added Button Clicked and End Edit event handlers
master
Chris Gregan 9 years ago
parent
commit
d91defa5ed
  1. 9
      Assets/Fungus/UI/Scripts/EventHandlers.meta
  2. 36
      Assets/Fungus/UI/Scripts/EventHandlers/ButtonClicked.cs
  3. 12
      Assets/Fungus/UI/Scripts/EventHandlers/ButtonClicked.cs.meta
  4. 36
      Assets/Fungus/UI/Scripts/EventHandlers/EndEdit.cs
  5. 12
      Assets/Fungus/UI/Scripts/EventHandlers/EndEdit.cs.meta
  6. 78
      Assets/FungusExamples/InputText/InputText.unity

9
Assets/Fungus/UI/Scripts/EventHandlers.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0329da317386d4617bc27cf9df87783a
folderAsset: yes
timeCreated: 1441985730
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

36
Assets/Fungus/UI/Scripts/EventHandlers/ButtonClicked.cs

@ -0,0 +1,36 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
namespace Fungus
{
[EventHandlerInfo("UI",
"Button Clicked",
"The block will execute when the user clicks on the target UI button object.")]
[AddComponentMenu("")]
public class ButtonClicked : EventHandler
{
[Tooltip("The UI Button that the user can click on")]
public Button targetButton;
public virtual void Start()
{
targetButton.onClick.AddListener(OnButtonClick);
}
protected virtual void OnButtonClick()
{
ExecuteBlock();
}
public override string GetSummary()
{
if (targetButton != null)
{
return targetButton.name;
}
return "None";
}
}
}

12
Assets/Fungus/UI/Scripts/EventHandlers/ButtonClicked.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 10eaeba5e91be479e95d4fa48679f549
timeCreated: 1441985740
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

36
Assets/Fungus/UI/Scripts/EventHandlers/EndEdit.cs

@ -0,0 +1,36 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
namespace Fungus
{
[EventHandlerInfo("UI",
"End Edit",
"The block will execute when the user finishes editing the text in the input field.")]
[AddComponentMenu("")]
public class EndEdit : EventHandler
{
[Tooltip("The UI Input Field that the user can enter text into")]
public InputField targetInputField;
public virtual void Start()
{
targetInputField.onEndEdit.AddListener(OnEndEdit);
}
protected virtual void OnEndEdit(string text)
{
ExecuteBlock();
}
public override string GetSummary()
{
if (targetInputField != null)
{
return targetInputField.name;
}
return "None";
}
}
}

12
Assets/Fungus/UI/Scripts/EventHandlers/EndEdit.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5942d3ed820e745b2beca47228bac126
timeCreated: 1441987431
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

78
Assets/FungusExamples/InputText/InputText.unity

@ -37,9 +37,6 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
--- !u!127 &3
LevelGameManager:
m_ObjectHideFlags: 0
--- !u!157 &4
LightmapSettings:
m_ObjectHideFlags: 0
@ -68,6 +65,7 @@ LightmapSettings:
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherRayCount: 1024
m_ReflectionCompression: 2
m_LightmapSnapshot: {fileID: 0}
m_RuntimeCPUUsage: 25
--- !u!196 &5
@ -117,6 +115,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: .196078435, g: .196078435, b: .196078435, a: .5}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
@ -167,6 +171,7 @@ GameObject:
- 114: {fileID: 163283985}
- 114: {fileID: 163283986}
- 114: {fileID: 163283989}
- 114: {fileID: 163283990}
m_Layer: 0
m_Name: Flowchart
m_TagString: Untagged
@ -198,7 +203,7 @@ MonoBehaviour:
y: -340
width: 1114
height: 859
selectedBlock: {fileID: 0}
selectedBlock: {fileID: 163283984}
selectedCommands: []
variables:
- {fileID: 163283985}
@ -227,13 +232,13 @@ MonoBehaviour:
nodeRect:
serializedVersion: 2
x: 67
y: 69
y: 70
width: 120
height: 40
itemId: 0
blockName: ReadText
description:
eventHandler: {fileID: 0}
eventHandler: {fileID: 163283990}
commandList:
- {fileID: 163283988}
- {fileID: 163283986}
@ -324,6 +329,19 @@ MonoBehaviour:
activeState:
booleanRef: {fileID: 0}
booleanVal: 0
--- !u!114 &163283990
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 163283982}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10eaeba5e91be479e95d4fa48679f549, type: 3}
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 163283984}
targetButton: {fileID: 373310154}
--- !u!1 &373310152
GameObject:
m_ObjectHideFlags: 0
@ -398,18 +416,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 373310155}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 163283983}
m_MethodName: ExecuteBlock
m_Mode: 5
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument: ReadText
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &373310155
@ -425,6 +432,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
@ -486,6 +499,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: .196078435, g: .196078435, b: .196078435, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
@ -534,7 +553,7 @@ MonoBehaviour:
m_Script: {fileID: 1997211142, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AllowActivationOnStandalone: 0
m_ForceModuleActive: 0
--- !u!114 &708657493
MonoBehaviour:
m_ObjectHideFlags: 0
@ -552,7 +571,7 @@ MonoBehaviour:
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: .5
m_AllowActivationOnMobileDevice: 0
m_ForceModuleActive: 0
--- !u!114 &708657494
MonoBehaviour:
m_ObjectHideFlags: 0
@ -647,6 +666,7 @@ Camera:
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
@ -713,6 +733,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: .39199999}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
@ -876,6 +902,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
@ -937,6 +969,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: .196078435, g: .196078435, b: .196078435, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14

Loading…
Cancel
Save