Base Scene

This commit is contained in:
2020-02-03 00:21:00 +00:00
parent 446510acc4
commit 739f87a1e4
142 changed files with 20574 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
using Exsersewo.Nydaliv.Extensions;
using System.Collections;
using UnityEngine;
namespace Exsersewo.UI.ProgressBar
{
public class ProgressBar : MonoBehaviour
{
[SerializeField]
RectTransform ValueSlider;
public ProgressBarType FillType;
[Tooltip("X=Left Y=Right")]
public Vector2 Padding;
[SerializeField]
ProgressTransitionType Transition;
[SerializeField]
float TransitionTime = .5f;
[SerializeField]
float previousValue;
RectTransform RectTransform;
void Start()
{
RectTransform = GetComponent<RectTransform>();
previousValue = ValueSlider.rect.width;
}
IEnumerator SetWidth(ulong value, ulong maxValue)
{
float hori = RectTransform.rect.width;
var width = ((float)value).Remap(0, maxValue, 0, hori-(Padding.x+Padding.y));
switch (Transition)
{
case ProgressTransitionType.Lerp:
case ProgressTransitionType.SmoothStep:
{
float TimeLerped = 0f;
while (TimeLerped <= TransitionTime)
{
float lerpVal = 0;
switch (Transition)
{
case ProgressTransitionType.SmoothStep:
lerpVal = Mathf.SmoothStep(previousValue, width, TimeLerped / TransitionTime);
break;
case ProgressTransitionType.Lerp:
lerpVal = Mathf.Lerp(previousValue, width, TimeLerped / TransitionTime);
break;
}
SetSliderPosition(lerpVal);
TimeLerped += Time.deltaTime;
yield return null;
}
}
break;
case ProgressTransitionType.Instant:
default:
{
SetSliderPosition(width);
}
break;
}
previousValue = width;
}
void SetSliderPosition(float val)
{
switch (FillType)
{
case ProgressBarType.FillFromCenter:
ValueSlider.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, val);
break;
case ProgressBarType.FillFromLeft:
ValueSlider.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, val);
ValueSlider.SetLeft(Padding.x);
break;
case ProgressBarType.FillFromRight:
ValueSlider.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, val);
ValueSlider.SetRight(Padding.y);
break;
}
}
public void SetValue(ulong value, ulong maxValue)
{
StartCoroutine(SetWidth(value, maxValue));
}
}
public enum ProgressBarType
{
FillFromCenter,
FillFromLeft,
FillFromRight
}
public enum ProgressTransitionType
{
Instant,
Lerp,
SmoothStep
}
}

View File

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

View File

@@ -0,0 +1,6 @@
namespace Exsersewo.UI.ProgressBar
{
public class ProgressBarWithLabel : ProgressBar
{
}
}

View File

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