added some stuff
This commit is contained in:
parent
9b69003715
commit
3dbf2f9010
520 changed files with 176780 additions and 2 deletions
|
@ -0,0 +1,110 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
namespace Lemon.GenericLib.UI
|
||||
{
|
||||
public class ImageUIManager : MonoBehaviour
|
||||
{
|
||||
public static ImageUIManager Instance;
|
||||
//singleton pattern
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
if (Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[SerializeField] ImageUIData[] ImageUIList;
|
||||
|
||||
[Serializable]
|
||||
struct ImageUIData
|
||||
{
|
||||
public string UIName;
|
||||
public Image ImageUI;
|
||||
public float fillRate;
|
||||
public float targetFill;
|
||||
public float snapFillMargin;
|
||||
|
||||
public void UpdateFill()
|
||||
{
|
||||
if (ImageUI.fillAmount == targetFill) return;
|
||||
ImageUI.fillAmount = Mathf.Lerp(ImageUI.fillAmount, targetFill, fillRate * Time.deltaTime);
|
||||
|
||||
if (Mathf.Abs(targetFill - ImageUI.fillAmount) <= snapFillMargin) ImageUI.fillAmount = targetFill;
|
||||
}
|
||||
|
||||
public void SetFill(float value)
|
||||
{
|
||||
targetFill = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
for (int i = 0; i < ImageUIList.Length; i++)
|
||||
{
|
||||
ImageUIList[i].UpdateFill();
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetFill(string UIName, float fill)
|
||||
{
|
||||
for (int i = 0; i < ImageUIList.Length; i++)
|
||||
{
|
||||
if (UIName == ImageUIList[i].UIName)
|
||||
{
|
||||
ImageUIList[i].SetFill(fill);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogError(" Image UI of nane " + UIName + " does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public bool SetFillForce(string UIName, float fill)
|
||||
{
|
||||
for (int i = 0; i < ImageUIList.Length; i++)
|
||||
{
|
||||
if (UIName == ImageUIList[i].UIName)
|
||||
{
|
||||
ImageUIList[i].ImageUI.fillAmount = fill;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogError(" Image UI of nane " + UIName + " does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetImage(string UIName, Sprite image)
|
||||
{
|
||||
for (int i = 0; i < ImageUIList.Length; i++)
|
||||
{
|
||||
if (UIName == ImageUIList[i].UIName)
|
||||
{
|
||||
ImageUIList[i].ImageUI.sprite = image;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogError(" Image UI of nane " + UIName + " does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6113c552c6f9e94190849ea5044d042
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,112 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using TMPro;
|
||||
|
||||
namespace Lemon.GenericLib.UI
|
||||
{
|
||||
public class TextUIManager : MonoBehaviour
|
||||
{
|
||||
|
||||
public static TextUIManager Instance;
|
||||
//singleton pattern
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
if (Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
InitTextUI();
|
||||
|
||||
}
|
||||
|
||||
public void InitTextUI()
|
||||
{
|
||||
for (int i = 0; i < textUIList.Length; i++)
|
||||
{
|
||||
textUIList[i].InitUI();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] TextUI[] textUIList;
|
||||
|
||||
[Serializable]
|
||||
struct TextUI
|
||||
{
|
||||
public string UIName;
|
||||
public TextMeshProUGUI textMesh;
|
||||
public bool textGoUp;
|
||||
public float textGoUpDistance;
|
||||
public float textEffectTime;
|
||||
public LeanTweenType easeType;
|
||||
[SerializeField] private Vector3 originalPos;
|
||||
private bool canAnimate;
|
||||
[SerializeField] private bool explixitDefineStartY;
|
||||
[SerializeField] Vector3 startPos;
|
||||
|
||||
|
||||
|
||||
public void SetText(string text)
|
||||
{
|
||||
textMesh.text = text;
|
||||
if (textGoUp && canAnimate) LeanTween.moveLocalY(textMesh.gameObject, originalPos.y + textGoUpDistance, textEffectTime).setOnComplete(AnimateEffectBack);
|
||||
}
|
||||
|
||||
public void SetColour(Color colour)
|
||||
{
|
||||
textMesh.color = colour;
|
||||
|
||||
}
|
||||
|
||||
public void InitUI()
|
||||
{
|
||||
if (explixitDefineStartY) originalPos = startPos;
|
||||
else originalPos = textMesh.GetComponent<RectTransform>().localPosition;
|
||||
canAnimate = true;
|
||||
}
|
||||
|
||||
private void AnimateEffectBack()
|
||||
{
|
||||
LeanTween.moveLocalY(textMesh.gameObject, originalPos.y, textEffectTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool SetText(string UIName, string text)
|
||||
{
|
||||
for (int i = 0; i < textUIList.Length; i++)
|
||||
{
|
||||
if (UIName == textUIList[i].UIName)
|
||||
{
|
||||
textUIList[i].SetText(text);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogError("text UI of nane " + UIName + " does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetColour(string UIName, Color colour)
|
||||
{
|
||||
for (int i = 0; i < textUIList.Length; i++)
|
||||
{
|
||||
if (UIName == textUIList[i].UIName)
|
||||
{
|
||||
textUIList[i].SetColour(colour);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogError("text UI of nane " + UIName + " does not exist");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 454e8a3504cc8734c861860dfef3875f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue