Added Sliders. Added Level Select, How To Play,. Credits Options Canvases layout for in main menu. Added Tweening Manager(Script) #369

Merged
maverickdgg merged 7 commits from SP3-20-UI-System into main 2023-02-27 12:00:24 +08:00
25 changed files with 508 additions and 21 deletions
Showing only changes of commit f23853c85c - Show all commits

View File

@ -0,0 +1,8 @@
- VertexShader: 46580970
FragmentShader: 35983630
SubPass: UI
Properties:
data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 51158984
data.alpha: 1
data.beta: {x: 1, y: 1, z: 1}

View File

@ -0,0 +1,3 @@
Name: GameIcon
ID: 126117259
Type: 7

View File

@ -1,7 +1,7 @@
- EID: 0 - EID: 0
Name: MainMenu Canvas Name: Main Menu Canvas
IsActive: true IsActive: true
NumberOfChildren: 4 NumberOfChildren: 8
Components: Components:
Canvas Component: Canvas Component:
Canvas Width: 1920 Canvas Width: 1920
@ -10,12 +10,12 @@
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 1 - EID: 1
Name: Background Name: BackGround
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 5, z: 0.5} Translate: {x: 0, y: 0, z: 0.5}
Rotate: {x: 0, y: 0, z: 0} Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1920, y: 1080, z: 1} Scale: {x: 1920, y: 1080, z: 1}
IsActive: true IsActive: true
@ -35,9 +35,9 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 75, z: 0.400000006} Translate: {x: -700, y: 100, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0} Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1} Scale: {x: 450, y: 100, z: 1}
IsActive: true IsActive: true
Renderable Component: Renderable Component:
Mesh: 141771688 Mesh: 141771688
@ -57,15 +57,23 @@
- Type: ChangeSceneButton - Type: ChangeSceneButton
Enabled: true Enabled: true
sceneID: 96668835 sceneID: 96668835
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: event:/Music/player_undetected
onHoverExitSound: event:/Music/player_undetected
onClickSound: event:/Music/player_undetected
onReleaseSound: event:/Music/player_undetected
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 6 - EID: 6
Name: Quit Game Button Name: Quit Game Button
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: -200, z: 0.400000006} Translate: {x: -700, y: -400, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0} Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 400, y: 200, z: 1} Scale: {x: 450, y: 100, z: 1}
IsActive: true IsActive: true
Renderable Component: Renderable Component:
Mesh: 141771688 Mesh: 141771688
@ -84,29 +92,171 @@
Scripts: Scripts:
- Type: QuitButton - Type: QuitButton
Enabled: true Enabled: true
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: event:/Music/player_undetected
onHoverExitSound: event:/Music/player_undetected
onClickSound: event:/Music/player_undetected
onReleaseSound: event:/Music/player_undetected
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 7 - EID: 7
Name: Slider Name: Level Select Button
IsActive: false IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: -56, z: 0} Translate: {x: -700, y: 0, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0} Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 500, y: 100, z: 1} Scale: {x: 450, y: 100, z: 1}
IsActive: false IsActive: true
Renderable Component: Renderable Component:
Mesh: 141771688 Mesh: 141771688
Material: 128676209 Material: 129340704
IsActive: false IsActive: true
Slider Component: Button Component:
Slider Value: 0 Default Texture: 52901020
IsActive: false Hovered Texture: 62235279
Clicked Texture: 64722619
IsActive: true
UI Component: UI Component:
Canvas ID: 0 Canvas ID: 0
Hovered: false Hovered: false
Clicked: false Clicked: false
IsActive: false IsActive: true
Scripts: ~ Scripts:
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: event:/Music/player_undetected
onHoverExitSound: event:/Music/player_undetected
onClickSound: event:/Music/player_undetected
onReleaseSound: event:/Music/player_undetected
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 9
Name: How To Play Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -700, y: -100, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 450, y: 100, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 52901020
Hovered Texture: 62235279
Clicked Texture: 64722619
IsActive: true
UI Component:
Canvas ID: 0
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: event:/Music/player_undetected
onHoverExitSound: event:/Music/player_undetected
onClickSound: event:/Music/player_undetected
onReleaseSound: event:/Music/player_undetected
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 10
Name: Credits Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -700, y: -200, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 450, y: 100, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 52901020
Hovered Texture: 62235279
Clicked Texture: 64722619
IsActive: true
UI Component:
Canvas ID: 0
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: event:/Music/player_undetected
onHoverExitSound: event:/Music/player_undetected
onClickSound: event:/Music/player_undetected
onReleaseSound: event:/Music/player_undetected
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 11
Name: Options Button
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -700, y: -300, z: 0.400000006}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 450, y: 100, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 52901020
Hovered Texture: 62235279
Clicked Texture: 64722619
IsActive: true
UI Component:
Canvas ID: 0
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.ButtonFX
Enabled: true
onHoverEnterSound: event:/Music/player_undetected
onHoverExitSound: event:/Music/player_undetected
onClickSound: event:/Music/player_undetected
onReleaseSound: event:/Music/player_undetected
hoverScale: 1.10000002
clickScale: 0.899999976
- EID: 12
Name: Game Icon
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -700, y: 350, z: 0.300000012}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 300, y: 300, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 126117259
IsActive: true
UI Component:
Canvas ID: 0
Hovered: false
Clicked: false
IsActive: true
Scripts:
- Type: SHADE_Scripting.UI.ScaleBounce
Enabled: true
minScale: 1
maxScale: 1.20000005
duration: 1.5
- EID: 2 - EID: 2
Name: Light Name: Light
IsActive: true IsActive: true
@ -152,4 +302,12 @@
- Type: MainMenu - Type: MainMenu
Enabled: true Enabled: true
sceneID: 96668835 sceneID: 96668835
obj: 1 obj: 1
- EID: 8
Name: TweenManager
IsActive: true
NumberOfChildren: 0
Components: ~
Scripts:
- Type: SHADE_Scripting.UI.TweenManager
Enabled: true

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public enum EASING_METHOD
{
EASE_IN_SINE,
EASE_OUT_SINE,
}
public static class EasingHelper
{
public static float EaseHelp(float value, EASING_METHOD method)
{
switch (method)
{
case EASING_METHOD.EASE_IN_SINE:
{
return EaseInSine(value);
}break;
case EASING_METHOD.EASE_OUT_SINE:
{
return EaseOutSine(value);
}break;
default:
return 0.0f;
}
}
private static float EaseInSine(float value)
{
return (float)(1.0f - Math.Cos((value * Math.PI) / 2.0f));
}
private static float EaseOutSine(float value)
{
return (float)(1.0f - Math.Sin(value * Math.PI) / 2.0f);
}
}
}

View File

@ -0,0 +1,3 @@
Name: EasingHelper
ID: 161000975
Type: 9

View File

@ -0,0 +1,87 @@
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class ButtonFX:Script
{
public string onHoverEnterSound = "event:/Music/player_undetected";
public string onHoverExitSound = "event:/Music/player_undetected";
public string onClickSound = "event:/Music/player_undetected";
public string onReleaseSound = "event:/Music/player_undetected";
[NonSerialized]
private AudioClipHandler onHoverEnterACHandler;
[NonSerialized]
private AudioClipHandler onHoverExitACHandler;
[NonSerialized]
private AudioClipHandler onClickACHandler;
[NonSerialized]
private AudioClipHandler onReleaseACHandler;
[NonSerialized]
private Vector3 defaultScale;
public float hoverScale = 1.1f;
public float clickScale = 0.9f;
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()
{
Transform transform = GetComponent<Transform>();
if (transform == null)
return;
defaultScale = transform.LocalScale;
UIElement ui = GetComponent<UIElement>();
if (ui == null)
return;
ui.OnClick.RegisterAction(() =>
{
onClickACHandler.Play();
transform.LocalScale = defaultScale * clickScale;
});
ui.OnRelease.RegisterAction(() =>
{
onReleaseACHandler.Play();
transform.LocalScale = defaultScale;
});
ui.OnHoverEnter.RegisterAction(() =>
{
onHoverEnterACHandler.Play();
transform.LocalScale = defaultScale * hoverScale;
});
ui.OnHoverExit.RegisterAction(() =>
{
onHoverExitACHandler.Play();
transform.LocalScale = defaultScale;
});
}
protected override void update()
{
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_ButtonFX
ID: 163796084
Type: 9

View File

@ -25,6 +25,7 @@ public class ChangeSceneButton : Script
else else
{ {
Debug.LogError("Failed to register button action for ChangeSceneButton."); Debug.LogError("Failed to register button action for ChangeSceneButton.");
} }
} }
protected override void update() protected override void update()

View File

@ -0,0 +1,47 @@
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
public class ScaleBounce:Script
{
[NonSerialized]
private TweenThread thread;
public float minScale = 1.0f;
public float maxScale = 1.2f;
public float duration = 1.0f;
private Vector3 defaultScale;
protected override void start()
{
thread = TweenManager.CreateTweenThread(duration, minScale, maxScale, EASING_METHOD.EASE_IN_SINE);
Transform trans = GetComponent<Transform>();
if(trans != null)
{
defaultScale = trans.LocalScale;
}
}
protected override void update()
{
Transform trans = GetComponent<Transform>();
if(trans != null)
{
trans.LocalScale = defaultScale * thread.GetValue();
}
if(thread.IsCompleted())
{
thread.ResetInvert();
}
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_ScaleBounce
ID: 152015842
Type: 9

View File

@ -0,0 +1,120 @@
using SHADE;
using SHADE_Scripting.Audio;
using System;
using System.Collections.Generic;
using System.Threading;
namespace SHADE_Scripting.UI
{
public class TweenThread
{
private float timer = 0.0f;
public float duration = 1.0f;
public EASING_METHOD method;
private float value = 0.0f;
public float startValue = 0.0f;
public float endValue = 1.0f;
public TweenThread(float duration, float startValue, float endValue, EASING_METHOD method)
{
this.duration = duration;
this.method = method;
this.startValue = startValue;
this.endValue = endValue;
}
public void Update(float deltaTime)
{
if (timer > duration)
return;
timer += deltaTime;
if (timer > duration)
timer = duration;
value = EasingHelper.EaseHelp(timer/duration, method) * (endValue - startValue) + startValue ;
}
public bool IsCompleted()
{
return timer >= duration;
}
public void Reset()
{
timer = 0.0f;
value = startValue;
}
public void Reset(float startValue, float endValue)
{
Reset();
this.startValue = startValue;
this.endValue = endValue;
}
public void ResetInvert()
{
Reset();
float temp = startValue;
startValue = endValue;
endValue = temp;
}
public float GetValue()
{
return value;
}
}
public class TweenManager : Script
{
public static TweenManager Instance { get; private set; }
[NonSerialized]
private List<TweenThread> threadList;
protected override void awake()
{
if (Instance != null && Instance != this)
RemoveScript<TweenManager>();
else
Instance = this;
threadList = new List<TweenThread>();
}
protected override void onDestroy()
{
if (Instance == this)
Instance = null;
}
protected override void update()
{
foreach (TweenThread thread in threadList)
{
thread.Update(Time.DeltaTimeF);
}
}
public static TweenThread CreateTweenThread(float duration, float startValue, float endValue, EASING_METHOD method)
{
if (Instance == null)
return null;
TweenThread thread = new TweenThread(duration, startValue, endValue, method);
Instance.threadList.Add(thread);
thread.Reset();
return thread;
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_TweenManager
ID: 164072799
Type: 9

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Name: RaccoonTransparent
ID: 51158984
Type: 3