add project files

This commit is contained in:
Boris Nikolaev
2026-08-14 01:58:31 +03:00
parent 9134cad79b
commit 5f1e94b653
4399 changed files with 12286903 additions and 0 deletions
@@ -0,0 +1,108 @@
using UnityEngine;
using UnityEngine.UI;
using OHM.UnityToolkit.Localization;
namespace OHM.UnityToolkit.UI
{
public class UIIncrementableCounter : MonoBehaviour
{
[SerializeField]
public float delay;
[SerializeField]
public float incDuration = 0.1f;
[SerializeField]
public Animator animator;
[SerializeField]
public TextWrapper text;
[SerializeField]
public bool localized;
[SerializeField]
[TextArea]
public string strFormat;
private long targetValue;
private float _lastTargetChangeTime;
private long _lastTargetChangeValue;
public long currentValue { get; set; }
public void Init(long value)
{
targetValue = value;
SetCurrentValue(value);
}
public void SetTargetValue(long value)
{
if (targetValue == value)
{
return;
}
if (animator != null && animator.gameObject.activeSelf)
{
if (value > targetValue)
{
animator.ResetTrigger("Decrement");
animator.SetTrigger("Increment");
}
else
{
animator.ResetTrigger("Increment");
animator.SetTrigger("Decrement");
}
}
_lastTargetChangeTime = Time.unscaledTime;
_lastTargetChangeValue = currentValue;
targetValue = value;
}
private void Awake()
{
}
private void Update()
{
if (currentValue == targetValue)
{
return;
}
float t = (Time.unscaledTime - _lastTargetChangeTime - delay) / incDuration;
if (t < 0f)
{
return;
}
if (t >= 1f)
{
SetCurrentValue(targetValue);
return;
}
SetCurrentValue((long)Mathf.Lerp(_lastTargetChangeValue, targetValue, t));
}
private void SetCurrentValue(long value)
{
currentValue = value;
string display;
if (string.IsNullOrEmpty(strFormat))
{
display = value.ToString();
}
else
{
string format = (localized ? LocalizationUtils.Localize(LocalizationManager.Instance.CurrentLocale, strFormat) : strFormat);
display = string.Format(format, value);
}
if (text != null)
{
text.text = display;
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2161e4642056bc06a65d4705d923b9c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,164 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Serialization;
namespace OHM.UnityToolkit.UI
{
public class UIIncrementableGauge : MonoBehaviour
{
[SerializeField]
private float incSpeed = 1f;
[SerializeField]
private float decSpeed = 1f;
[SerializeField]
private float levelincSpeed = 1f;
[SerializeField]
public RectTransform gaugeRect;
[SerializeField]
[FormerlySerializedAs("gaugeImage")]
private Image _gaugeImage;
[SerializeField]
[FormerlySerializedAs("imageMaxFillRatio")]
private float _imageMaxFillRatio = 1f;
[SerializeField]
[FormerlySerializedAs("x")]
private bool _x;
[SerializeField]
[FormerlySerializedAs("y")]
private bool _y;
[SerializeField]
[FormerlySerializedAs("smoothLevelUp")]
private bool _smoothLevelUp;
[SerializeField]
[FormerlySerializedAs("smoothLevelDown")]
private bool _smoothLevelDown;
private int currentLevel;
private int _targetLevel;
private float _targetValue;
public float CurrentValue { get; set; }
private void Awake()
{
currentLevel = 0;
CurrentValue = 0f;
_targetValue = 0f;
SetRawValue(0f);
}
public void SetTargetValue(float value, int level)
{
if (_targetValue == value && _targetLevel == level)
{
return;
}
_targetValue = Mathf.Clamp01(value);
_targetLevel = level;
}
public void QuickResetToLevel(int level, float value = 0, bool force = false)
{
_targetValue = value;
currentLevel = level;
_targetLevel = level;
if (force)
{
CurrentValue = value;
}
SetRawValue(value);
}
private bool IncValueToTarget(float target, float speed)
{
float current = CurrentValue;
bool rising = target - current >= 0f;
float next = current + (rising ? Time.deltaTime : (0f - Time.deltaTime)) * speed;
bool reached;
if (rising)
{
reached = next >= target;
if (reached)
{
next = target;
}
}
else
{
reached = next <= target;
if (reached)
{
next = target;
}
}
SetRawValue(next);
return reached;
}
private void LevelTransition(bool smooth, int deltaLevel, float target, float afterValue)
{
if (!smooth)
{
currentLevel += deltaLevel;
SetRawValue(_targetValue);
return;
}
if (IncValueToTarget(target, levelincSpeed))
{
currentLevel += deltaLevel;
SetRawValue(afterValue);
}
}
private void Update()
{
if (_targetLevel == currentLevel)
{
if (_targetValue > CurrentValue)
{
IncValueToTarget(_targetValue, incSpeed);
}
else if (_targetValue <= CurrentValue)
{
IncValueToTarget(_targetValue, decSpeed);
}
}
else if (_targetLevel > currentLevel)
{
LevelTransition(_smoothLevelUp, 1, 1f, 0f);
}
else
{
LevelTransition(_smoothLevelDown, -1, 0f, 1f);
}
}
private void SetRawValue(float value)
{
CurrentValue = value;
float ratio = Mathf.Clamp01(value);
if (gaugeRect != null)
{
Vector2 anchorMax = gaugeRect.anchorMax;
gaugeRect.anchorMax = new Vector2(_x ? ratio : anchorMax.x, _y ? ratio : anchorMax.y);
}
if (_gaugeImage != null)
{
_gaugeImage.fillAmount = ratio * _imageMaxFillRatio;
}
}
public void changeGaugeColor(Color color)
{
_gaugeImage.color = color;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 840746e70fee1eaead3c9e35da62c31f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,127 @@
using System;
using UnityEngine;
using UnityEngine.Events;
namespace OHM.UnityToolkit.UI
{
public class UIMenuBase : MonoBehaviour
{
[SerializeField]
protected Animator animator;
[SerializeField]
protected GameObject toEnableOnShow;
[SerializeField]
protected bool hideOnBack;
public UIMenuEvent onShow = new UIMenuEvent();
public UIMenuEvent onHide = new UIMenuEvent();
public UIMenuInteractionEvent onInteraction = new UIMenuInteractionEvent();
protected UIMenusController menuController;
private void Awake()
{
}
internal void SetMenuController(UIMenusController menuController)
{
this.menuController = menuController;
}
public virtual void Show()
{
base.gameObject.SetActive(value: true);
if (toEnableOnShow != null)
{
toEnableOnShow.SetActive(value: true);
}
ResetTrigger("Hide");
int? trigger = GetAnimParameter("Show");
if (trigger.HasValue)
{
animator.SetTrigger(trigger.Value);
}
onShow.Invoke(base.name);
if (menuController != null)
{
menuController.PushPopup(this);
}
}
public virtual void Hide()
{
onHide.Invoke(base.name);
if (menuController != null)
{
menuController.PopPopup(this);
}
ResetTrigger("Show");
int? trigger = GetAnimParameter("Hide");
if (trigger.HasValue)
{
animator.SetTrigger(trigger.Value);
}
else
{
base.gameObject.SetActive(value: false);
}
}
public void DisableNow()
{
base.gameObject.SetActive(value: false);
}
protected void ResetTrigger(string id)
{
int? trigger = GetAnimParameter(id);
if (trigger.HasValue)
{
animator.ResetTrigger(trigger.Value);
}
}
protected Nullable<int> GetAnimParameter(string name)
{
if (animator != null && animator.gameObject.activeSelf)
{
AnimatorControllerParameter[] parameters = animator.parameters;
for (int i = 0; i < parameters.Length; i++)
{
if (parameters[i].name == name)
{
return parameters[i].nameHash;
}
}
}
return null;
}
protected void OnInteraction(string interactionId)
{
onInteraction.Invoke(base.name, interactionId);
}
public virtual bool OnBack()
{
if (!hideOnBack)
{
return false;
}
Hide();
return true;
}
[Serializable]
public class UIMenuEvent : UnityEvent<string>
{
}
[Serializable]
public class UIMenuInteractionEvent : UnityEvent<string, string>
{
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6a12e645c9c64c5561bde3ff087a26ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,91 @@
using System.Collections.Generic;
using UnityEngine;
namespace OHM.UnityToolkit.UI
{
public class UIMenusController : MonoBehaviour
{
public UIMenuBase defaultMenu;
private List<UIMenuBase> _popupStack = new List<UIMenuBase>();
public UIMenuBase[] AllSubMenus { get; set; }
private void Awake()
{
InitSubMenus();
if (defaultMenu != null)
{
HideAllExcept(defaultMenu);
}
else
{
HideAll();
}
}
private void InitSubMenus()
{
AllSubMenus = GetComponentsInChildren<UIMenuBase>(true);
for (int i = 0; i < AllSubMenus.Length; i++)
{
InitSubMenu(AllSubMenus[i]);
}
}
protected virtual void InitSubMenu(UIMenuBase menu)
{
menu.SetMenuController(this);
}
public void HideAll()
{
for (int i = 0; i < AllSubMenus.Length; i++)
{
AllSubMenus[i].Hide();
}
}
public void HideAllExcept(UIMenuBase except)
{
for (int i = 0; i < AllSubMenus.Length; i++)
{
UIMenuBase menu = AllSubMenus[i];
if (menu != except)
{
menu.Hide();
}
}
}
public void ShowDebug(bool state)
{
}
public void PushPopup(UIMenuBase popup)
{
_popupStack.Add(popup);
}
public void PopPopup(UIMenuBase popup)
{
_popupStack.RemoveAll((UIMenuBase p) => p == popup);
}
public void Update()
{
if (!Input.GetKeyUp(KeyCode.Escape))
{
return;
}
var stack = new List<UIMenuBase>(_popupStack);
for (int i = stack.Count - 1; i >= 0; i--)
{
if (stack[i].OnBack())
{
break;
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 616d43cbcd2b2c9f08094843492913c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
using OHM.UnityToolkit;
using OHM.UnityToolkit.Pooling;
namespace OHM.UnityToolkit.UI
{
public class UIMoveToTarget : MonoBehaviour, PooledObjectListener
{
[SerializeField]
private RectTransform rectTransform;
[SerializeField]
public RectTransform target;
[SerializeField]
public float initialDelay;
[SerializeField]
public float animDuration;
[SerializeField]
public AnimationCurve xCurve;
[SerializeField]
public AnimationCurve yCurve;
[SerializeField]
public bool autoStart = true;
[SerializeField]
public bool destroyOnEnd;
public UnityEvent onMoveDone = new UnityEvent();
private void Start()
{
ComponentsUtils.GetRequiredComponent(this, ref rectTransform);
if (autoStart)
{
StartCoroutine(MoveAnim());
}
}
public void StartMove()
{
StartCoroutine(MoveAnim());
}
private IEnumerator MoveAnim()
{
yield return new WaitForEndOfFrame();
yield return new WaitForSeconds(initialDelay);
Vector2 from = rectTransform.anchoredPosition;
var delta = (Vector2)target.localPosition - from;
for (float t = animDuration; t > 0f; t -= Time.deltaTime)
{
float ratio = 1f - t / animDuration;
rectTransform.anchoredPosition = new Vector2(
from.x + xCurve.Evaluate(ratio) * delta.x,
from.y + yCurve.Evaluate(ratio) * delta.y);
yield return new WaitForEndOfFrame();
}
onMoveDone.Invoke();
if (destroyOnEnd)
{
PoolsManager.ReleaseObject(base.gameObject);
}
}
public void OnEnable()
{
StartCoroutine(MoveAnim());
}
public void OnRelease()
{
}
public void OnReset()
{
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 92a9b3325dba89d6ab3eb8c111a45a60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,19 @@
using UnityEngine;
using UnityEngine.UI;
namespace OHM.UnityToolkit.UI
{
public class UITouchable : Graphic
{
public override bool Raycast(Vector2 sp, Camera eventCamera)
{
return true;
}
protected override void OnPopulateMesh(VertexHelper vh)
{
vh.Clear();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eef9f966ce5bd70aad00e4025069964d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: