mirror of
https://github.com/Steffo99/better-tee.git
synced 2024-11-21 06:44:19 +00:00
Commit stuff
This commit is contained in:
parent
ed3b2112a8
commit
ac13119f7a
12 changed files with 117 additions and 4 deletions
8
Assets/Refactored/Form.meta
Normal file
8
Assets/Refactored/Form.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59f7c51047fec274ba0547d089d6c24b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,9 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterTee.Form {
|
||||
public class Form : MonoBehaviour {
|
||||
private Dictionary<string, FormItem> registeredItems;
|
||||
private Dictionary<string, FormEvent> registeredButtons;
|
||||
|
||||
protected void Start() {
|
||||
registeredItems = new Dictionary<string, FormItem>();
|
||||
|
@ -28,5 +30,19 @@ namespace BetterTee.Form {
|
|||
public void SetValue(string name, dynamic 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2b707d16fe3a3ef44ac2219497fa45e6
|
||||
guid: a5c867ac4d014de45917ee8b07537457
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
16
Assets/Refactored/Form/FormButton.cs
Normal file
16
Assets/Refactored/Form/FormButton.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Refactored/Form/FormButton.cs.meta
Normal file
11
Assets/Refactored/Form/FormButton.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c46a67a8eb1b0db4fa2c16c74b2bb40e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Refactored/Form/FormButtonUnity.cs
Normal file
18
Assets/Refactored/Form/FormButtonUnity.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Refactored/Form/FormButtonUnity.cs.meta
Normal file
11
Assets/Refactored/Form/FormButtonUnity.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e56d115fefbe1f945bd8a59584ad056a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
7
Assets/Refactored/Form/FormElement.cs
Normal file
7
Assets/Refactored/Form/FormElement.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace BetterTee.Form {
|
||||
public abstract class FormElement : MonoBehaviour {
|
||||
public string Name;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace BetterTee.Form {
|
||||
public abstract class FormItem : MonoBehaviour {
|
||||
public string Name;
|
||||
|
||||
public abstract class FormItem : FormElement {
|
||||
public abstract dynamic Value {get; set;}
|
||||
}
|
||||
}
|
||||
|
|
11
Assets/Refactored/Form/FormItem.cs.meta
Normal file
11
Assets/Refactored/Form/FormItem.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b88fa2a04c90654a875ec8da4cf6501
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,9 +1,15 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace BetterTee.Form {
|
||||
[RequireComponent(typeof(InputField))]
|
||||
public class FormItemTextField : FormItem {
|
||||
protected InputField inputFieldComponent;
|
||||
|
||||
protected void Start() {
|
||||
inputFieldComponent = GetComponent<inputFieldComponent>();
|
||||
}
|
||||
|
||||
public override dynamic Value {
|
||||
get {
|
||||
return inputFieldComponent.text;
|
11
Assets/Refactored/Form/FormItemTextField.cs.meta
Normal file
11
Assets/Refactored/Form/FormItemTextField.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3cee61e182b2cd0409e9871770d97423
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue