continuing with combat, sword combos working, not finished, blockign working, need to build blockpush and improving bow combat

This commit is contained in:
2026-09-30 16:39:18 +01:00
parent 7486c8d310
commit 4980fb8128
2095 changed files with 1069655 additions and 652 deletions

View File

@@ -0,0 +1,314 @@
// Copyright (c) 2025 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.EventSystems;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
// compile errors?
using UnityEngine.InputSystem.UI;
// compile errors?
// if you are getting a compile error here you likely need to import the Input System package (com.unity.inputsystem) in the package manager or change the input setting in player settings back to 'Input Manager (Old)'
#endif
namespace Synty.Interface.FantasyMenus.Samples
{
public enum UnifiedKey
{
None,
// Letters
A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
// Digits
Digit0, Digit1, Digit2, Digit3, Digit4,
Digit5, Digit6, Digit7, Digit8, Digit9,
// Numpad
Numpad0, Numpad1, Numpad2, Numpad3, Numpad4,
Numpad5, Numpad6, Numpad7, Numpad8, Numpad9,
// Arrows
UpArrow, DownArrow, LeftArrow, RightArrow,
// Function Keys
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
// Controls
Space, Enter, Tab, Backspace, Escape,
LeftShift, RightShift, LeftCtrl, RightCtrl, LeftAlt, RightAlt,
}
public static class UnifiedKeyConverter
{
#if ENABLE_LEGACY_INPUT_MANAGER
public static KeyCode? ToKeyCode(this UnifiedKey key)
{
switch (key)
{
case UnifiedKey.A: return KeyCode.A;
case UnifiedKey.B: return KeyCode.B;
case UnifiedKey.C: return KeyCode.C;
case UnifiedKey.D: return KeyCode.D;
case UnifiedKey.E: return KeyCode.E;
case UnifiedKey.F: return KeyCode.F;
case UnifiedKey.G: return KeyCode.G;
case UnifiedKey.H: return KeyCode.H;
case UnifiedKey.I: return KeyCode.I;
case UnifiedKey.J: return KeyCode.J;
case UnifiedKey.K: return KeyCode.K;
case UnifiedKey.L: return KeyCode.L;
case UnifiedKey.M: return KeyCode.M;
case UnifiedKey.N: return KeyCode.N;
case UnifiedKey.O: return KeyCode.O;
case UnifiedKey.P: return KeyCode.P;
case UnifiedKey.Q: return KeyCode.Q;
case UnifiedKey.R: return KeyCode.R;
case UnifiedKey.S: return KeyCode.S;
case UnifiedKey.T: return KeyCode.T;
case UnifiedKey.U: return KeyCode.U;
case UnifiedKey.V: return KeyCode.V;
case UnifiedKey.W: return KeyCode.W;
case UnifiedKey.X: return KeyCode.X;
case UnifiedKey.Y: return KeyCode.Y;
case UnifiedKey.Z: return KeyCode.Z;
case UnifiedKey.Digit0: return KeyCode.Alpha0;
case UnifiedKey.Digit1: return KeyCode.Alpha1;
case UnifiedKey.Digit2: return KeyCode.Alpha2;
case UnifiedKey.Digit3: return KeyCode.Alpha3;
case UnifiedKey.Digit4: return KeyCode.Alpha4;
case UnifiedKey.Digit5: return KeyCode.Alpha5;
case UnifiedKey.Digit6: return KeyCode.Alpha6;
case UnifiedKey.Digit7: return KeyCode.Alpha7;
case UnifiedKey.Digit8: return KeyCode.Alpha8;
case UnifiedKey.Digit9: return KeyCode.Alpha9;
case UnifiedKey.Numpad0: return KeyCode.Keypad0;
case UnifiedKey.Numpad1: return KeyCode.Keypad1;
case UnifiedKey.Numpad2: return KeyCode.Keypad2;
case UnifiedKey.Numpad3: return KeyCode.Keypad3;
case UnifiedKey.Numpad4: return KeyCode.Keypad4;
case UnifiedKey.Numpad5: return KeyCode.Keypad5;
case UnifiedKey.Numpad6: return KeyCode.Keypad6;
case UnifiedKey.Numpad7: return KeyCode.Keypad7;
case UnifiedKey.Numpad8: return KeyCode.Keypad8;
case UnifiedKey.Numpad9: return KeyCode.Keypad9;
case UnifiedKey.UpArrow: return KeyCode.UpArrow;
case UnifiedKey.DownArrow: return KeyCode.DownArrow;
case UnifiedKey.LeftArrow: return KeyCode.LeftArrow;
case UnifiedKey.RightArrow: return KeyCode.RightArrow;
case UnifiedKey.F1: return KeyCode.F1;
case UnifiedKey.F2: return KeyCode.F2;
case UnifiedKey.F3: return KeyCode.F3;
case UnifiedKey.F4: return KeyCode.F4;
case UnifiedKey.F5: return KeyCode.F5;
case UnifiedKey.F6: return KeyCode.F6;
case UnifiedKey.F7: return KeyCode.F7;
case UnifiedKey.F8: return KeyCode.F8;
case UnifiedKey.F9: return KeyCode.F9;
case UnifiedKey.F10: return KeyCode.F10;
case UnifiedKey.F11: return KeyCode.F11;
case UnifiedKey.F12: return KeyCode.F12;
case UnifiedKey.Space: return KeyCode.Space;
case UnifiedKey.Enter: return KeyCode.Return;
case UnifiedKey.Tab: return KeyCode.Tab;
case UnifiedKey.Backspace: return KeyCode.Backspace;
case UnifiedKey.Escape: return KeyCode.Escape;
case UnifiedKey.LeftShift: return KeyCode.LeftShift;
case UnifiedKey.RightShift: return KeyCode.RightShift;
case UnifiedKey.LeftCtrl: return KeyCode.LeftControl;
case UnifiedKey.RightCtrl: return KeyCode.RightControl;
case UnifiedKey.LeftAlt: return KeyCode.LeftAlt;
case UnifiedKey.RightAlt: return KeyCode.RightAlt;
default: return null;
}
}
#endif
#if ENABLE_INPUT_SYSTEM
public static Key? ToInputSystemKey(this UnifiedKey key)
{
switch (key)
{
case UnifiedKey.A: return Key.A;
case UnifiedKey.B: return Key.B;
case UnifiedKey.C: return Key.C;
case UnifiedKey.D: return Key.D;
case UnifiedKey.E: return Key.E;
case UnifiedKey.F: return Key.F;
case UnifiedKey.G: return Key.G;
case UnifiedKey.H: return Key.H;
case UnifiedKey.I: return Key.I;
case UnifiedKey.J: return Key.J;
case UnifiedKey.K: return Key.K;
case UnifiedKey.L: return Key.L;
case UnifiedKey.M: return Key.M;
case UnifiedKey.N: return Key.N;
case UnifiedKey.O: return Key.O;
case UnifiedKey.P: return Key.P;
case UnifiedKey.Q: return Key.Q;
case UnifiedKey.R: return Key.R;
case UnifiedKey.S: return Key.S;
case UnifiedKey.T: return Key.T;
case UnifiedKey.U: return Key.U;
case UnifiedKey.V: return Key.V;
case UnifiedKey.W: return Key.W;
case UnifiedKey.X: return Key.X;
case UnifiedKey.Y: return Key.Y;
case UnifiedKey.Z: return Key.Z;
case UnifiedKey.Digit0: return Key.Digit0;
case UnifiedKey.Digit1: return Key.Digit1;
case UnifiedKey.Digit2: return Key.Digit2;
case UnifiedKey.Digit3: return Key.Digit3;
case UnifiedKey.Digit4: return Key.Digit4;
case UnifiedKey.Digit5: return Key.Digit5;
case UnifiedKey.Digit6: return Key.Digit6;
case UnifiedKey.Digit7: return Key.Digit7;
case UnifiedKey.Digit8: return Key.Digit8;
case UnifiedKey.Digit9: return Key.Digit9;
case UnifiedKey.Numpad0: return Key.Numpad0;
case UnifiedKey.Numpad1: return Key.Numpad1;
case UnifiedKey.Numpad2: return Key.Numpad2;
case UnifiedKey.Numpad3: return Key.Numpad3;
case UnifiedKey.Numpad4: return Key.Numpad4;
case UnifiedKey.Numpad5: return Key.Numpad5;
case UnifiedKey.Numpad6: return Key.Numpad6;
case UnifiedKey.Numpad7: return Key.Numpad7;
case UnifiedKey.Numpad8: return Key.Numpad8;
case UnifiedKey.Numpad9: return Key.Numpad9;
case UnifiedKey.UpArrow: return Key.UpArrow;
case UnifiedKey.DownArrow: return Key.DownArrow;
case UnifiedKey.LeftArrow: return Key.LeftArrow;
case UnifiedKey.RightArrow: return Key.RightArrow;
case UnifiedKey.F1: return Key.F1;
case UnifiedKey.F2: return Key.F2;
case UnifiedKey.F3: return Key.F3;
case UnifiedKey.F4: return Key.F4;
case UnifiedKey.F5: return Key.F5;
case UnifiedKey.F6: return Key.F6;
case UnifiedKey.F7: return Key.F7;
case UnifiedKey.F8: return Key.F8;
case UnifiedKey.F9: return Key.F9;
case UnifiedKey.F10: return Key.F10;
case UnifiedKey.F11: return Key.F11;
case UnifiedKey.F12: return Key.F12;
case UnifiedKey.Space: return Key.Space;
case UnifiedKey.Enter: return Key.Enter;
case UnifiedKey.Tab: return Key.Tab;
case UnifiedKey.Backspace: return Key.Backspace;
case UnifiedKey.Escape: return Key.Escape;
case UnifiedKey.LeftShift: return Key.LeftShift;
case UnifiedKey.RightShift: return Key.RightShift;
case UnifiedKey.LeftCtrl: return Key.LeftCtrl;
case UnifiedKey.RightCtrl: return Key.RightCtrl;
case UnifiedKey.LeftAlt: return Key.LeftAlt;
case UnifiedKey.RightAlt: return Key.RightAlt;
default: return null;
}
}
#endif
}
public static class UnifiedInput
{
public static bool WasPressedThisFrame(UnifiedKey unifiedKey)
{
#if ENABLE_INPUT_SYSTEM
var key = unifiedKey.ToInputSystemKey();
if(key.HasValue) return Keyboard.current[key.Value].wasPressedThisFrame;
#elif ENABLE_LEGACY_INPUT_MANAGER
var keyCode = unifiedKey.ToKeyCode();
if(keyCode.HasValue) return Input.GetKeyDown(keyCode.Value);
#else
Debug.LogWarning("No input system enabled in project settings.");
#endif
return false;
}
public static bool IsPressed(UnifiedKey unifiedKey)
{
#if ENABLE_INPUT_SYSTEM
var key = unifiedKey.ToInputSystemKey();
if (key.HasValue) return Keyboard.current[key.Value].isPressed;
#elif ENABLE_LEGACY_INPUT_MANAGER
var keyCode = unifiedKey.ToKeyCode();
if(keyCode.HasValue) return Input.GetKey(keyCode.Value);
#else
Debug.LogWarning("No input system enabled in project settings.");
#endif
return false;
}
}
/// <summary>
/// Sample script that helps automatically select the correct input event module depending on your project's settings.
/// </summary>
[ExecuteAlways]
[RequireComponent(typeof(EventSystem))]
public class SampleAutoInputModule : MonoBehaviour
{
void OnEnable()
{
UpdateInputModule();
}
void UpdateInputModule()
{
#if ENABLE_INPUT_SYSTEM
// New Input System only
if (GetComponent<InputSystemUIInputModule>() == null)
{
// Remove any existing modules
foreach (var module in GetComponents<BaseInputModule>())
{
DestroyImmediate(module);
}
gameObject.AddComponent<InputSystemUIInputModule>();
if(!Application.isPlaying) Debug.Log("Added InputSystemUIInputModule (new input system)");
}
#elif ENABLE_LEGACY_INPUT_MANAGER
// Old Input Manager only
if (GetComponent<StandaloneInputModule>() == null)
{
// Remove any existing modules
foreach (var module in GetComponents<BaseInputModule>())
{
DestroyImmediate(module);
}
gameObject.AddComponent<StandaloneInputModule>();
if(!Application.isPlaying) Debug.Log("Added StandaloneInputModule (old input manager)");
}
#else
Debug.LogWarning("No input system enabled in project settings.");
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,51 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// http://www.syntystore.com
// http://www.unityassetstore.com
// http://www.fab.com
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// A sample script that simulates brightness settings.
/// </summary>
public class SampleBrightnessDisplay : MonoBehaviour
{
[Header("References")]
public Image image;
public Slider brightnessValueSlider;
[Header("Paramters")]
public float multiplier = 1;
public float min = 0;
public float max = 1;
Color defaultColor;
private void Awake()
{
defaultColor = image.color;
brightnessValueSlider.onValueChanged.AddListener(OnValueChanged);
OnValueChanged(brightnessValueSlider.value);
}
private void OnDestroy()
{
brightnessValueSlider.onValueChanged.RemoveListener(OnValueChanged);
}
private void OnValueChanged(float value)
{
image.color = defaultColor * Mathf.Lerp(min, max, value * multiplier);
}
}
}

View File

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

View File

@@ -0,0 +1,33 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Controls the activation state of button description objects
/// </summary>
public class SampleButtonDescriptions : MonoBehaviour
{
// Start is called before the first frame update
public void SetActive(GameObject description)
{
for(int i = 0; i < transform.childCount; ++i)
{
Transform child = transform.GetChild(i);
child.gameObject.SetActive( child.gameObject == description );
}
}
}
}

View File

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

View File

@@ -0,0 +1,59 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// http://www.syntystore.com
// http://www.unityassetstore.com
// http://www.fab.com
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Sets the default selected object on the EventSystem
/// </summary>
public class SampleDefaultSelectable : MonoBehaviour
{
[Header("References")]
public Selectable defaultSelectable;
bool started = false;
private void Start()
{
if (defaultSelectable != null)
{
defaultSelectable.Select();
}
started = true;
}
private void OnEnable()
{
if(!started)
{
return;
}
if (defaultSelectable != null)
{
defaultSelectable.Select();
}
}
public void Select()
{
if (defaultSelectable != null)
{
defaultSelectable.Select();
}
}
}
}

View File

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

View File

@@ -0,0 +1,82 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Allows the selection of a single option from an array of possible options
/// </summary>
public class SampleNavInputHelper : MonoBehaviour
{
public Toggle previous;
public Toggle next;
Toggle selectionToggle;
bool selectPrevious = false;
bool selectNext = false;
public void Awake()
{
selectionToggle = GetComponent<Toggle>();
}
public void Update()
{
if (selectionToggle != null && selectionToggle.isOn)
{
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.Q))
{
selectPrevious = true;
}
else if (UnifiedInput.WasPressedThisFrame(UnifiedKey.E))
{
selectNext = true;
}
}
}
public void LateUpdate()
{
if (selectPrevious)
{
SelectPrevious();
}
else if (selectNext)
{
SelectNext();
}
selectPrevious = false;
selectNext = false;
}
private void SelectPrevious()
{
if (previous != null )
{
previous.isOn = true;
}
}
private void SelectNext()
{
if (next != null )
{
next.isOn = true;
}
}
}
}

View File

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

View File

@@ -0,0 +1,44 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Events for on highlighted and on selected
/// </summary>
public class SampleOnButtonEvents : MonoBehaviour, IPointerEnterHandler, ISelectHandler
{
public UnityEvent onHighlighted;
public UnityEvent onSelected;
public void OnPointerEnter(PointerEventData eventData)
{
if(onHighlighted != null)
{
onHighlighted.Invoke();
}
}
public void OnSelect(BaseEventData eventData)
{
if(onSelected != null)
{
onSelected.Invoke();
}
}
}
}

View File

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

View File

@@ -0,0 +1,63 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Oscillates the value of a list of sliders.
/// </summary>
public class SampleOscillateSliders : MonoBehaviour
{
[Header("References")]
public List<Slider> sliders;
[Header("Parameters")]
public bool autoGetSliders = true;
public float speed = 1f;
public float offset = 0.5f;
private void GetSliders()
{
#if UNITY_2022_1_OR_NEWER
sliders = FindObjectsByType<Slider>(FindObjectsInactive.Exclude, FindObjectsSortMode.None).ToList();
#else
sliders = FindObjectsOfType<Slider>().ToList();
#endif
}
private void Reset()
{
GetSliders();
}
private void Start()
{
if (autoGetSliders)
{
GetSliders();
}
}
private void Update()
{
for (int i = 0; i < sliders.Count; i++)
{
sliders[i].value = (Mathf.Sin((Time.time * speed) + (i * offset)) * 0.5f) + 0.5f;
}
}
}
}

View File

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

View File

@@ -0,0 +1,97 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Sample script for a simple modal UI Popup
/// </summary>
public class SamplePopup : MonoBehaviour
{
[Header("References")]
public SamplePopup acceptObject;
public SamplePopup cancelObject;
public Selectable inputBlocker;
public Animator animator;
[Header("Parameters")]
public bool selfDismiss;
public float dismissTime;
bool dismissed = true;
// Update is called once per frame
private void Update()
{
if (dismissed)
{
return;
}
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.Enter))
{
if( acceptObject != null )
{
acceptObject.ShowMe();
}
DismissMe();
}
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.Escape))
{
if (cancelObject != null)
{
cancelObject.ShowMe();
}
DismissMe();
}
}
public void ShowMe()
{
CancelInvoke();
dismissed = false;
if (inputBlocker != null )
{
inputBlocker.gameObject.SetActive(true);
inputBlocker.Select();
}
gameObject.SetActive(false);
gameObject.SetActive(true);
animator.SetBool("Active", true);
if (selfDismiss)
{
Invoke("DisableMe", dismissTime);
}
}
public void DismissMe()
{
animator.SetBool("Active", false);
Invoke("DisableMe", dismissTime);
if (inputBlocker != null )
{
inputBlocker.gameObject.SetActive(false);
}
dismissed = true;
}
public void DisableMe()
{
gameObject.SetActive(false);
}
}
}

View File

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

View File

@@ -0,0 +1,131 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Sample for radial menu input
/// </summary>
public class SampleRadialMenuInput : MonoBehaviour
{
[Header("References")]
public Transform origin;
public Selectable[] selectables;
[Header("Paramters")]
[Range(0,1)]
public float currentSelectionBias = 0.1f;
private bool IsRadialMenuElementSelected()
{
for (int i = 0; i < selectables.Length; ++i)
{
if (EventSystem.current.currentSelectedGameObject == selectables[i].gameObject)
{
return true;
}
}
return false;
}
private float GetInput(string[] inputAxies)
{
float result = 0;
for (int i = 0; i < inputAxies.Length; ++i)
{
result += Input.GetAxisRaw(inputAxies[i]);
}
return result;
}
float GetHorizontal()
{
if(UnifiedInput.IsPressed(UnifiedKey.A) || UnifiedInput.IsPressed(UnifiedKey.LeftArrow))
{
return -1;
}
if(UnifiedInput.IsPressed(UnifiedKey.D) || UnifiedInput.IsPressed(UnifiedKey.RightArrow))
{
return 1;
}
return 0;
}
float GetVerticle()
{
if(UnifiedInput.IsPressed(UnifiedKey.S) || UnifiedInput.IsPressed(UnifiedKey.DownArrow))
{
return -1;
}
if(UnifiedInput.IsPressed(UnifiedKey.W) || UnifiedInput.IsPressed(UnifiedKey.UpArrow))
{
return 1;
}
return 0;
}
private void Update()
{
if (IsRadialMenuElementSelected() && !EventSystem.current.alreadySelecting)
{
// we're in focus. let's process our input!
Vector3 input = new Vector3( GetHorizontal(), GetVerticle(), 0);
if (input.magnitude > 0.1f)
{
Vector3 inputDirection = input.normalized;
Debug.DrawLine(origin.position, origin.position + inputDirection * 100, Color.red);
int bestFit = 0;
float bestDot = 0;
for (int i = 0; i < selectables.Length; ++i)
{
Debug.DrawLine(origin.position, selectables[i].transform.position, Color.green);
bool currentSelection = EventSystem.current.currentSelectedGameObject == selectables[i].gameObject;
Vector3 elementDirection = (selectables[i].transform.position - origin.position).normalized;
float testDot = Vector3.Dot(inputDirection, elementDirection) + (currentSelection ? currentSelectionBias : 0);
if (i == 0)
{
bestFit = 0;
bestDot = testDot;
continue;
}
if (testDot > bestDot)
{
bestDot = testDot;
bestFit = i;
}
}
if (EventSystem.current.currentSelectedGameObject != selectables[bestFit].gameObject)
{
selectables[bestFit].Select();
}
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,134 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;
#if UNITY_EDITOR
using System.IO;
using UnityEditor;
using UnityEditor.SceneManagement;
#endif
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// A simple scene loader that transitions between screens.
/// </summary>
public class SampleSceneLoader : MonoBehaviour
{
[Header("References")]
public Animator animator;
[Header("Parameters")]
public bool showCursor;
[SerializeField]
private List<string> _sceneNames;
#if UNITY_EDITOR
private void RefreshScenes()
{
MonoScript script = MonoScript.FromMonoBehaviour(this);
string samplesPath = Path.GetDirectoryName(Path.GetDirectoryName(AssetDatabase.GetAssetPath(script)));
string[] searchPaths = { Path.Combine(samplesPath, "Scenes") };
_sceneNames = AssetDatabase.FindAssets($"t:scene", searchPaths)
.Select(guid => Path.GetFileNameWithoutExtension(AssetDatabase.GUIDToAssetPath(guid)))
.ToList();
EditorUtility.SetDirty(this);
}
private void OnValidate()
{
RefreshScenes();
}
#endif
private void OnEnable()
{
if (animator)
{
animator.gameObject.SetActive(true);
animator.SetBool("Active", false);
}
if (showCursor)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
public void QuitApplication()
{
#if UNITY_EDITOR
EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
public void NextScene()
{
string currentScene = SceneManager.GetActiveScene().name;
SwitchScene(_sceneNames[(_sceneNames.IndexOf(currentScene) + 1) % _sceneNames.Count]);
}
public void PreviousScene()
{
string currentScene = SceneManager.GetActiveScene().name;
SwitchScene(_sceneNames[(_sceneNames.IndexOf(currentScene) - 1 + _sceneNames.Count) % _sceneNames.Count]);
}
public void SwitchScene(string sceneName)
{
#if UNITY_EDITOR
if (!EditorApplication.isPlaying)
{
return;
}
#endif
StartCoroutine(C_SwitchScene(sceneName));
}
private IEnumerator C_SwitchScene(string sceneName)
{
if (animator)
{
animator.gameObject.SetActive(true);
animator.SetBool("Active", true);
yield return new WaitForSeconds(0.5f);
}
#if UNITY_EDITOR
string path = sceneName;
if (path.IndexOf('/') == -1)
{
string guid = AssetDatabase.FindAssets($"{sceneName} t:scene")[0];
path = AssetDatabase.GUIDToAssetPath(guid);
}
yield return EditorSceneManager.LoadSceneAsyncInPlayMode(path, new LoadSceneParameters(LoadSceneMode.Single));
#else
// make sure the scene is in the build settings for runtime version
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName);
while (!asyncLoad.isDone)
{
yield return null;
}
#endif
}
}
}

View File

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

View File

@@ -0,0 +1,46 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Helper functions for the scroll rect component
/// </summary>
public static class ScrollRectExtensions
{
public static void SnapChildIntoView(this ScrollRect instance, RectTransform child)
{
instance.content.localPosition = GetSnapToPositionToBringChildIntoView(instance, child);
}
public static Vector3 GetSnapToPositionToBringChildIntoView(this ScrollRect instance, RectTransform child)
{
Canvas.ForceUpdateCanvases();
RectTransform rectTransform = instance.viewport != null ? instance.viewport : instance.GetComponent<RectTransform>();
Bounds childBounds = RectTransformUtility.CalculateRelativeRectTransformBounds(rectTransform, child);
float shiftDown = -Mathf.Max(0, childBounds.max.y - rectTransform.rect.yMax);
float shiftUp = -Mathf.Min(0, childBounds.min.y - rectTransform.rect.yMin);
float shiftLeft = -Mathf.Max(0, childBounds.max.x - rectTransform.rect.xMax);
float shiftRight = -Mathf.Min(0, childBounds.min.x - rectTransform.rect.xMin);
Vector3 shift = new Vector3( instance.horizontal ? shiftLeft + shiftRight : 0, instance.vertical ? shiftUp + shiftDown: 0, 0);
return instance.content.localPosition + shift;
}
}
}

View File

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

View File

@@ -0,0 +1,47 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Sample scroll window item. Snaps into view when selected
/// </summary>
public class SampleScrollRectSelectableListItem : MonoBehaviour
{
Selectable selectable;
bool wasSelected = false;
ScrollRect parentScrollRect;
private void Start()
{
parentScrollRect = GetComponentInParent<ScrollRect>();
selectable = GetComponentInChildren<Selectable>();
}
private void Update()
{
if (parentScrollRect != null && selectable != null)
{
bool isSelected = EventSystem.current.currentSelectedGameObject == selectable.gameObject;
if (!wasSelected && isSelected)
{
parentScrollRect.SnapChildIntoView(GetComponent<RectTransform>());
}
wasSelected = isSelected;
}
}
}
}

View File

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

View File

@@ -0,0 +1,72 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// http://www.syntystore.com
// http://www.unityassetstore.com
// http://www.fab.com
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Sample credits screen controller
/// </summary>
public class SampleScrollerInputs : MonoBehaviour
{
[Header("References")]
public RectTransform viewport;
public RectTransform content;
[Header("Parameters")]
public float speed;
public float speedChangeIncrement;
public float slowDownDistance = 200;
public float maxSpeed;
Vector3 startPosition;
float startSpeed;
private void Start()
{
startSpeed = speed;
startPosition = content.localPosition;
}
private void Reset()
{
content.localPosition = startPosition;
speed = startSpeed;
}
private void Update()
{
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.UpArrow) || UnifiedInput.WasPressedThisFrame(UnifiedKey.W))
{
speed = Mathf.Clamp( speed - speedChangeIncrement, -maxSpeed, 0);
}
else if (UnifiedInput.WasPressedThisFrame(UnifiedKey.DownArrow) || UnifiedInput.WasPressedThisFrame(UnifiedKey.S))
{
speed = Mathf.Clamp( speed + speedChangeIncrement, 0, maxSpeed);
}
float length = content.sizeDelta.y - viewport.rect.height;
float distanceTraveled = Vector3.Distance(content.localPosition, startPosition);
float distanceLeft = length - distanceTraveled;
if(speed < 0)
{
distanceLeft = distanceTraveled;
}
Vector3 delta = Vector3.up * Mathf.Lerp(speed, 0, Mathf.InverseLerp(slowDownDistance, 0, distanceLeft)) * Time.deltaTime;
content.localPosition = content.localPosition + delta;
}
}
}

View File

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

View File

@@ -0,0 +1,54 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Toggles referenced game object on and off an object based on the toggle's value
/// </summary>
public class SampleSelectedObjectActivator : MonoBehaviour
{
[Header("References")]
public Selectable selectable;
public GameObject isOnObject;
private void Start()
{
SetActiveObjects();
}
private void LateUpdate()
{
SetActiveObjects();
}
private void SetActiveObjects()
{
if (isOnObject != null)
{
if (!isOnObject.activeSelf && selectable != null && EventSystem.current.currentSelectedGameObject == selectable.gameObject)
{
isOnObject.SetActive(true);
}
if (isOnObject.activeSelf && selectable != null && EventSystem.current.currentSelectedGameObject != selectable.gameObject)
{
isOnObject.SetActive(false);
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,88 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using System.Collections.Generic;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Sample script that helps the application naivgate with the keyboard and controller
/// </summary>
public class SampleSelectedObjectHelper : MonoBehaviour
{
List<Selectable> selectedObjectHistory = new List<Selectable>();
int maxHistorySize = 1000;
private Selectable GetLastSelectedObject()
{
for (int i = selectedObjectHistory.Count-1; i >= 0; --i)
{
if(selectedObjectHistory[i] != null && selectedObjectHistory[i].gameObject.activeInHierarchy)
{
return selectedObjectHistory[i];
}
selectedObjectHistory.RemoveAt(i);
}
return null;
}
private void Update()
{
Selectable lastSelectedObject = GetLastSelectedObject();
Selectable currentSelectedObject = EventSystem.current.currentSelectedGameObject != null ? EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>() : null;
if (currentSelectedObject != null && currentSelectedObject.gameObject.activeInHierarchy && lastSelectedObject != EventSystem.current.currentSelectedGameObject)
{
if (selectedObjectHistory.Contains(currentSelectedObject))
{
selectedObjectHistory.Remove(currentSelectedObject);
}
selectedObjectHistory.Add(currentSelectedObject);
if ( selectedObjectHistory.Count > maxHistorySize )
{
selectedObjectHistory.RemoveAt(0);
}
}
else if (lastSelectedObject != null)
{
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.A) || UnifiedInput.WasPressedThisFrame(UnifiedKey.LeftArrow))
{
lastSelectedObject.Select();
return;
}
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.D) || UnifiedInput.WasPressedThisFrame(UnifiedKey.RightArrow))
{
lastSelectedObject.Select();
return;
}
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.S) || UnifiedInput.WasPressedThisFrame(UnifiedKey.DownArrow))
{
lastSelectedObject.Select();
return;
}
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.W) || UnifiedInput.WasPressedThisFrame(UnifiedKey.UpArrow))
{
lastSelectedObject.Select();
return;
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,149 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Allow the selection of a single option from an array of possible options
/// </summary>
public class SampleSettingsArray : MonoBehaviour
{
[Header("References")]
public TMP_Text valueLabel;
public Button left;
public Button right;
public Selectable selectable;
[Space]
public UnityEvent<int, string> onValueChanged;
[Header("Parameters")]
public string[] options;
public int defaultOption = 0;
public bool loop = false;
public int OptionIndex => optionIndex;
public string Option => options.Length > 0 ? options[optionIndex] : "";
private int optionIndex;
private void OnValidate()
{
SetDefaultOption();
}
private void Start()
{
SetDefaultOption();
if (left != null)
{
left.onClick.AddListener(OnLeftClick);
}
if (right != null)
{
right.onClick.AddListener(OnRightClick);
}
}
private void Update()
{
if (selectable != null && EventSystem.current.currentSelectedGameObject == selectable.gameObject)
{
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.A) || UnifiedInput.WasPressedThisFrame(UnifiedKey.LeftArrow))
{
OnLeftClick();
}
else if (UnifiedInput.WasPressedThisFrame(UnifiedKey.D) || UnifiedInput.WasPressedThisFrame(UnifiedKey.RightArrow))
{
OnRightClick();
}
}
}
private void UpdateUI()
{
if (options.Length == 0)
{
valueLabel.SetText("");
}
else
{
valueLabel.SetText(options[optionIndex]);
}
}
public void SetOption(int newOption)
{
if (newOption < 0)
{
if (loop)
{
newOption = options.Length-1;
}
else
{
newOption = 0;
}
}
if (newOption >= options.Length)
{
if (loop)
{
newOption = 0;
}
else
{
newOption = options.Length - 1;
}
}
if (left != null)
{
left.interactable = loop || newOption > 0;
}
if (right != null)
{
right.interactable = loop || newOption < options.Length-1;
}
if (optionIndex != newOption)
{
optionIndex = newOption;
onValueChanged?.Invoke(optionIndex, options[optionIndex]);
}
UpdateUI();
}
public void OnLeftClick()
{
SetOption( optionIndex-1 );
}
public void OnRightClick()
{
SetOption( optionIndex+1 );
}
public void SetDefaultOption()
{
SetOption( defaultOption );
}
}
}

View File

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

View File

@@ -0,0 +1,64 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.Serialization;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Toggles on and off game objects based on the array's value
/// </summary>
public class SampleSettingsArrayObject : MonoBehaviour
{
[Header("References")]
public SampleSettingsArray arraySetting;
[Tooltip("Populated from arraySettings")]
public string[] options;
[FormerlySerializedAs("gameObejects")]
public GameObject[] gameObjects;
private void OnValidate()
{
if(arraySetting == null)
{
return;
}
options = arraySetting.options;
}
private void Awake()
{
if (arraySetting != null)
{
arraySetting.onValueChanged.AddListener(OnValueChanged);
OnValueChanged(arraySetting.OptionIndex, arraySetting.Option);
}
}
private void OnDestroy()
{
if (arraySetting != null)
{
arraySetting.onValueChanged.RemoveListener(OnValueChanged);
}
}
private void OnValueChanged(int index, string option)
{
for (int i = 0; i < gameObjects.Length; i++)
{
if (gameObjects[i] != null) gameObjects[i].SetActive(index == i);
}
}
}
}

View File

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

View File

@@ -0,0 +1,89 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// A settings slider that sets a value between a range
/// </summary>
public class SampleSettingsSlider : MonoBehaviour
{
[Header("References")]
public TMP_Text valueLabel;
public Slider valueSlider;
public Selectable selectable;
public Button left;
public Button right;
[Header("Parameters")]
public float sliderStep = 1;
public string valueFormat = "##0";
private void Start()
{
if (left != null)
{
left.onClick.AddListener(OnLeftClick);
}
if (right != null)
{
right.onClick.AddListener(OnRightClick);
}
if(valueSlider != null)
{
valueSlider.onValueChanged.AddListener(OnValueChanged);
OnValueChanged(valueSlider.value);
}
}
private void Update()
{
if (selectable != null && EventSystem.current.currentSelectedGameObject == selectable.gameObject)
{
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.A) || UnifiedInput.WasPressedThisFrame(UnifiedKey.LeftArrow))
{
OnLeftClick();
}
else if (UnifiedInput.WasPressedThisFrame(UnifiedKey.D) || UnifiedInput.WasPressedThisFrame(UnifiedKey.RightArrow))
{
OnRightClick();
}
}
}
public void OnValueChanged(float value)
{
valueLabel.SetText( value.ToString(valueFormat) );
}
public void SetValue(float newValue)
{
valueSlider.value = newValue;
}
public void OnLeftClick()
{
valueSlider.value = valueSlider.value - sliderStep;
}
public void OnRightClick()
{
valueSlider.value = valueSlider.value + sliderStep;
}
}
}

View File

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

View File

@@ -0,0 +1,121 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Sample script to allow controller and keyboard input for a toggle group
/// </summary>
public class SampleSettingsToggle : MonoBehaviour
{
[Header("References")]
public Selectable selectable;
public GameObject toggleGroupParent;
[Header("Parameters")]
public bool loop = false;
Toggle[] toggles;
int defaultToggle = 0;
private void Start()
{
toggles = toggleGroupParent.GetComponentsInChildren<Toggle>();
for (int i = 0; i < toggles.Length; ++i)
{
if (toggles[i].isOn)
{
defaultToggle = i;
break;
}
}
}
private void Update()
{
if (selectable != null && EventSystem.current.currentSelectedGameObject == selectable.gameObject)
{
if (UnifiedInput.WasPressedThisFrame(UnifiedKey.A) || UnifiedInput.WasPressedThisFrame(UnifiedKey.LeftArrow))
{
PreviousToggle();
}
else if (UnifiedInput.WasPressedThisFrame(UnifiedKey.D) || UnifiedInput.WasPressedThisFrame(UnifiedKey.RightArrow))
{
NextToggle();
}
}
}
private void NextToggle()
{
if (toggles.Length == 0 )
{
return;
}
for (int i = 0; i < toggles.Length; ++i)
{
if (toggles[i].isOn)
{
int next = i+1;
if (next >= toggles.Length)
{
if(!loop) return;
next = 0;
}
toggles[next].isOn = true;
return;
}
}
}
private void PreviousToggle()
{
if (toggles.Length == 0 )
{
return;
}
for (int i = 0; i < toggles.Length; ++i)
{
if (toggles[i].isOn)
{
int next = i-1;
if(next < 0)
{
if(!loop) return;
next = toggles.Length - 1;
}
toggles[next].isOn = true;
return;
}
}
SelectDefaultToggle();
}
private void SelectDefaultToggle()
{
if (toggles.Length > 0)
{
return;
}
toggles[defaultToggle].isOn = true;
}
}
}

View File

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

View File

@@ -0,0 +1,62 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Adds animator boolean parameter that reflects the toggle's state
/// </summary>
public class SampleToggleAnimatorEvents : MonoBehaviour
{
private Toggle toggle;
private Animator animator;
private void Awake()
{
toggle = GetComponent<Toggle>();
animator = GetComponent<Animator>();
if (toggle != null)
{
toggle.onValueChanged.AddListener(OnValueChanged);
OnValueChanged(toggle.isOn);
}
}
private void OnEnable()
{
if (toggle != null)
{
OnValueChanged(toggle.isOn);
}
}
private void OnDestroy()
{
if (toggle != null)
{
toggle.onValueChanged.RemoveListener(OnValueChanged);
}
}
private void OnValueChanged(bool value)
{
if (animator != null)
{
animator.SetBool( "ToggleIsOn", value );
}
}
}
}

View File

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

View File

@@ -0,0 +1,87 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Extended toggle functionality
/// </summary>
public class SampleToggleHelper : MonoBehaviour
{
private Toggle toggle;
private Animator animator;
public void Awake()
{
toggle = GetComponent<Toggle>();
animator = GetComponent<Animator>();
if (toggle != null)
{
toggle.onValueChanged.AddListener(OnValueChanged);
OnValueChanged(toggle.isOn);
}
}
private void OnEnable()
{
if (toggle != null)
{
OnValueChanged(toggle.isOn);
}
}
private void OnDestroy()
{
if (toggle != null)
{
toggle.onValueChanged.RemoveListener(OnValueChanged);
}
}
private void LateUpdate()
{
bool selected = EventSystem.current.currentSelectedGameObject == toggle.gameObject;
if (selected != toggle.isOn)
{
SetToggle(selected);
}
}
public void SetToggle(bool value)
{
if (toggle != null)
{
toggle.isOn = value;
}
}
public void Toggle()
{
if (toggle != null)
{
SetToggle(!toggle.isOn);
}
}
private void OnValueChanged(bool value)
{
if (animator != null)
{
animator.SetBool( "ToggleIsOn", value );
}
}
}
}

View File

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

View File

@@ -0,0 +1,59 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.UI;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Toggles on and off game objects based on the toggle's value
/// </summary>
public class SampleToggleObjectActivator : MonoBehaviour
{
[Header("References")]
public Toggle toggle;
public GameObject isOnObject;
public GameObject isOffObject;
private void Awake()
{
if (toggle != null)
{
toggle.onValueChanged.AddListener(OnValueChanged);
OnValueChanged(toggle.isOn);
}
}
private void OnDestroy()
{
if (toggle != null)
{
toggle.onValueChanged.RemoveListener(OnValueChanged);
}
}
private void OnValueChanged(bool value)
{
if (isOnObject != null)
{
isOnObject.SetActive(value);
}
if (isOffObject != null)
{
isOffObject.SetActive(!value);
}
}
}
}

View File

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

View File

@@ -0,0 +1,45 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// 'Hot key' binding for the referenced button.
/// </summary>
public class SampleUIButtonInput : MonoBehaviour
{
[Header("References")]
public Button button;
[Header("Parameters")]
public UnifiedKey key;
public UnifiedKey secondaryKey = UnifiedKey.None;
private void Update()
{
if(UnifiedInput.WasPressedThisFrame(key) || UnifiedInput.WasPressedThisFrame(secondaryKey))
{
EventSystem eventSystem = GameObject.FindAnyObjectByType<EventSystem>();
if(eventSystem != null && button != null )
{
ExecuteEvents.Execute(button.gameObject, new BaseEventData(eventSystem), ExecuteEvents.submitHandler);
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,27 @@
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the End User Licence Agreement (EULA)
// of the store at which you purchased this asset.
//
// Synty assets are available at:
// https://www.syntystore.com
// https://assetstore.unity.com/publishers/5217
// https://www.fab.com/sellers/Synty%20Studios
//
// Sample scripts are included only as examples and are not intended as production-ready.
using UnityEngine;
namespace Synty.Interface.FantasyMenus.Samples
{
/// <summary>
/// Opens a URL in the default browser.
/// </summary>
public class SampleURL : MonoBehaviour
{
public void OpenURL(string url)
{
Application.OpenURL(url);
}
}
}

View File

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