Button FX now uses the easing functions. Viewport can now be fixed at an AR. #371

Merged
maverickdgg merged 3 commits from SP3-20-UI-System into main 2023-02-27 15:28:55 +08:00
6 changed files with 155 additions and 33 deletions
Showing only changes of commit 08e4db134a - Show all commits

View File

@ -1,4 +1,4 @@
Start Maximized: true
Working Scene ID: 97158628
Working Scene ID: 86098106
Window Size: {x: 1920, y: 1013}
Style: 0

View File

@ -4,5 +4,5 @@
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 57302694
data.alpha: 0
data.alpha: 1
data.beta: {x: 1, y: 1, z: 1}

View File

@ -9591,27 +9591,14 @@
gamePauseText: 11
canvas: 10
- EID: 199
Name: =====Text====
Name: Gameplay UI Canvas
IsActive: true
NumberOfChildren: 4
Components: ~
Scripts: ~
- EID: 237
Name: Score
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -800, y: 400, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60, y: 60, z: 60}
IsActive: true
Text Renderer Component:
Text: My name is Brandon.
Font: 176667660
IsActive: true
UI Component:
Canvas ID: 199
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 206
@ -9630,6 +9617,8 @@
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 139
@ -9648,6 +9637,8 @@
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 11
@ -9664,6 +9655,51 @@
Text: Game Pause
Font: 176667660
IsActive: false
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 462
Name: Score BG
IsActive: true
NumberOfChildren: 1
Components:
Transform Component:
Translate: {x: -900, y: 450, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 100, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 237
Name: Score Text
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -0.050249815, y: -0.300000191, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 0.150000006, y: 0.600000024, z: 60}
IsActive: true
Text Renderer Component:
Text: My name is Brandon.
Font: 176667660
IsActive: true
UI Component:
Canvas ID: 199
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 198
Name: ====Raccoon====
@ -9765,7 +9801,6 @@
Yaw: 360
Roll: 1.28065994e-06
Width: 1055
Height: 604
Near: 0.00999999978
Far: 10000
Perspective: true
@ -10664,6 +10699,7 @@
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
Scripts: ~
- EID: 8
@ -10687,6 +10723,8 @@
IsActive: true
UI Component:
Canvas ID: 10
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 0
@ -10710,6 +10748,8 @@
IsActive: true
UI Component:
Canvas ID: 10
Hovered: false
Clicked: false
IsActive: true
Scripts: ~
- EID: 461
@ -10733,5 +10773,7 @@
IsActive: true
UI Component:
Canvas ID: 10
Hovered: false
Clicked: false
IsActive: true
Scripts: ~

View File

@ -21,7 +21,7 @@
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 121834459
Material: 129138332
IsActive: true
UI Component:
Canvas ID: 0
@ -1024,14 +1024,14 @@
maxValue: 100
- EID: 46
Name: Credits Canvas
IsActive: true
IsActive: false
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
IsActive: false
Scripts: ~
- EID: 47
Name: BackGround
@ -1103,14 +1103,14 @@
Scripts: ~
- EID: 50
Name: Level Select Canvas
IsActive: true
IsActive: false
NumberOfChildren: 3
Components:
Canvas Component:
Canvas Width: 1920
Canvas Height: 1080
Scale by canvas width: false
IsActive: true
IsActive: false
Scripts: ~
- EID: 51
Name: BackGround

View File

@ -11,6 +11,9 @@ namespace SHADE_Scripting.UI
{
EASE_IN_SINE,
EASE_OUT_SINE,
EASE_OUT_BOUNCE,
EASE_IN_BOUNCE,
EASE_INOUT_BOUNCE
}
public static class EasingHelper
@ -28,7 +31,20 @@ namespace SHADE_Scripting.UI
{
return EaseOutSine(value);
}break;
case EASING_METHOD.EASE_OUT_BOUNCE:
{
return EaseOutBounce(value);
}break;
case EASING_METHOD.EASE_IN_BOUNCE:
{
return EaseInBounce(value);
}
break;
case EASING_METHOD.EASE_INOUT_BOUNCE:
{
return EaseInOutBounce(value);
}
break;
default:
return 0.0f;
}
@ -44,5 +60,37 @@ namespace SHADE_Scripting.UI
return (float)(1.0f - Math.Sin(value * Math.PI) / 2.0f);
}
private static float EaseOutBounce(float value)
{
const float n1 = 7.5625f;
const float d1 = 2.75f;
if (value < 1.0f / d1)
{
return n1 * value * value;
} else if (value < 2.0f / d1)
{
return n1 * (value -= 2.25f / d1) * value + 0.9375f;
}
else
{
return n1 * (value -= 2.625f / d1) * value + 0.984375f;
}
}
private static float EaseInBounce(float value)
{
return 1 - EaseOutBounce(1 - value);
}
private static float EaseInOutBounce(float value)
{
return (value < 0.5f)
?(1.0f - EaseOutBounce(1.0f - 2.0f * value)) / 2.0f
: (1.0f + EaseOutBounce(2.0f * value - 1.0f)) / 2.0f;
}
}
}

View File

@ -30,16 +30,30 @@ namespace SHADE_Scripting.UI
public float clickScale = 0.9f;
[NonSerialized]
private TweenThread thread;
[NonSerialized]
private bool tweening = false;
[NonSerialized]
private float currentScale = 1.0f;
protected override void awake()
{
onHoverEnterACHandler = SHADE.Audio.CreateAudioClip(onHoverEnterSound);
onHoverExitACHandler = SHADE.Audio.CreateAudioClip(onHoverExitSound);
onClickACHandler = SHADE.Audio.CreateAudioClip(onClickSound);
onReleaseACHandler = SHADE.Audio.CreateAudioClip(onReleaseSound);
}
protected override void start()
{
thread = TweenManager.CreateTweenThread(0.1f, 0.9f, 1.0f, EASING_METHOD.EASE_IN_SINE);
Transform transform = GetComponent<Transform>();
if (transform == null)
return;
@ -55,35 +69,53 @@ namespace SHADE_Scripting.UI
{
if (onClickSound != "")
onClickACHandler.Play();
transform.LocalScale = defaultScale * clickScale;
tweening = true;
if(thread != null)
thread.Reset(currentScale,clickScale);
});
ui.OnRelease.RegisterAction(() =>
{
if (onReleaseSound != "")
onReleaseACHandler.Play();
transform.LocalScale = defaultScale;
tweening = true;
if (thread != null)
thread.Reset(currentScale, 1.0f);
});
ui.OnHoverEnter.RegisterAction(() =>
{
if (onHoverEnterSound != "")
onHoverEnterACHandler.Play();
transform.LocalScale = defaultScale * hoverScale;
tweening = true;
if (thread != null)
thread.Reset(currentScale, hoverScale);
});
ui.OnHoverExit.RegisterAction(() =>
{
if (onHoverExitSound != "")
onHoverExitACHandler.Play();
transform.LocalScale = defaultScale;
tweening = true;
if (thread != null)
thread.Reset(currentScale, 1.0f);
});
}
protected override void update()
{
Transform transform = GetComponent<Transform>();
if (transform == null)
return;
if (tweening == true && thread != null)
{
Debug.Log("Tweening value " + thread.GetValue());
transform.LocalScale = defaultScale * thread.GetValue();
currentScale = thread.GetValue();
if (thread.IsCompleted())
tweening = false;
}
}