1
Fork 0
mirror of https://github.com/Steffo99/better-tee.git synced 2024-11-21 14:54:18 +00:00

Commit stuff

This commit is contained in:
Steffo 2019-09-23 18:44:56 +02:00
parent ed3b2112a8
commit ac13119f7a
12 changed files with 117 additions and 4 deletions

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 59f7c51047fec274ba0547d089d6c24b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +1,11 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace BetterTee.Form { namespace BetterTee.Form {
public class Form : MonoBehaviour { public class Form : MonoBehaviour {
private Dictionary<string, FormItem> registeredItems; private Dictionary<string, FormItem> registeredItems;
private Dictionary<string, FormEvent> registeredButtons;
protected void Start() { protected void Start() {
registeredItems = new Dictionary<string, FormItem>(); registeredItems = new Dictionary<string, FormItem>();
@ -28,5 +30,19 @@ namespace BetterTee.Form {
public void SetValue(string name, dynamic value) { public void SetValue(string name, dynamic value) {
registeredItems[name].Value = value; registeredItems[name].Value = value;
} }
public void RegisterButton(FormEvent button) {
registeredButtons.Add(button.name, button);
}
public void UnregisterButton(string name) {
FormEvent button = registeredButtons[name];
button.UnsubscribeAll();
registeredButtons.Remove(name);
}
public void SubscribeTo(string name, Action<FormEvent> handler) {
registeredButtons[name].OnTrigger += handler;
}
} }
} }

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 2b707d16fe3a3ef44ac2219497fa45e6 guid: a5c867ac4d014de45917ee8b07537457
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View file

@ -0,0 +1,16 @@
using System;
using UnityEngine;
namespace BetterTee.Form {
public abstract class FormEvent : FormElement {
public event Action<FormEvent> OnTrigger;
protected void TriggerEvent() {
OnTrigger(this);
}
public void UnsubscribeAll() {
OnTrigger = null;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c46a67a8eb1b0db4fa2c16c74b2bb40e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,18 @@
using UnityEngine;
using UnityEngine.UI;
namespace BetterTee.Form {
[RequireComponent(typeof(Button))]
public class FormButtonUnity : FormEvent {
protected Button buttonComponent;
private void Start() {
buttonComponent = GetComponent<Button>();
buttonComponent.onClick.AddListener(ButtonComponent_OnClick);
}
private void ButtonComponent_OnClick() {
TriggerEvent();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e56d115fefbe1f945bd8a59584ad056a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,7 @@
using UnityEngine;
namespace BetterTee.Form {
public abstract class FormElement : MonoBehaviour {
public string Name;
}
}

View file

@ -1,9 +1,7 @@
using UnityEngine; using UnityEngine;
namespace BetterTee.Form { namespace BetterTee.Form {
public abstract class FormItem : MonoBehaviour { public abstract class FormItem : FormElement {
public string Name;
public abstract dynamic Value {get; set;} public abstract dynamic Value {get; set;}
} }
} }

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b88fa2a04c90654a875ec8da4cf6501
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,9 +1,15 @@
using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
namespace BetterTee.Form { namespace BetterTee.Form {
[RequireComponent(typeof(InputField))]
public class FormItemTextField : FormItem { public class FormItemTextField : FormItem {
protected InputField inputFieldComponent; protected InputField inputFieldComponent;
protected void Start() {
inputFieldComponent = GetComponent<inputFieldComponent>();
}
public override dynamic Value { public override dynamic Value {
get { get {
return inputFieldComponent.text; return inputFieldComponent.text;

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3cee61e182b2cd0409e9871770d97423
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: