Skip to content

Commit 5bb1a19

Browse files
authored
Merge pull request #4 from coryleach/dev
Merge 2.0.0
2 parents a4aec17 + 8d9a69e commit 5bb1a19

File tree

77 files changed

+749
-678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+749
-678
lines changed

.codacy.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
exclude_paths:
2+
- '*.md'
3+
- 'Tests/Editor/*.cs'
4+
- 'Tests/Runtime/*.cs'

Editor/GUIEditor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public static void NestAnimationClips()
4646
AssetDatabase.AddObjectToAsset(newClip, controller);
4747
Debug.Log("Added & Will Import: " + AssetDatabase.GetAssetPath(newClip));
4848
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newClip));
49-
//AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(oldClip));
5049
}
5150
}
5251

README.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<h1 align="center">Gameframe.GUI 👋</h1>
2-
<p>
3-
<img alt="Version" src="https://img.shields.io/badge/version-1.1.3-blue.svg?cacheSeconds=2592000" />
4-
<a href="https://twitter.com/Cory Leach">
5-
<img alt="Twitter: coryleach" src="https://img.shields.io/twitter/follow/coryleach.svg?style=social" target="_blank" />
6-
</a>
7-
</p>
2+
3+
<!-- BADGE-START -->
4+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/325ed211df6d42b980b7cdbc9afe5eb7)](https://www.codacy.com/manual/coryleach/UnityGUI?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=coryleach/UnityGUI&amp;utm_campaign=Badge_Grade)
5+
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/coryleach/UnityGui?include_prereleases)
6+
[![openupm](https://img.shields.io/npm/v/com.gameframe.gui?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.gameframe.gui/)
7+
[![license](https://img.shields.io/github/license/coryleach/UnityGui)](https://github.com/coryleach/UnityGui/blob/master/LICENSE)
8+
9+
[![twitter](https://img.shields.io/twitter/follow/coryleach.svg?style=social)](https://twitter.com/coryleach)
10+
<!-- BADGE-END -->
811

912
This is a library of GUI helpers for UGUI
1013
Includes a panel system that implements a navigation stack.
@@ -16,22 +19,22 @@ Includes a shader for blurring the background of UI panels.
1619
#### Using UnityPackageManager (for Unity 2019.3 or later)
1720
Open the package manager window (menu: Window > Package Manager)<br/>
1821
Select "Add package from git URL...", fill in the pop-up with the following link:<br/>
19-
https://github.com/coryleach/UnityGUI.git#1.1.3<br/>
22+
https://github.com/coryleach/UnityGUI.git#2.0.0<br/>
2023

2124
#### Using UnityPackageManager (for Unity 2019.1 or later)
2225

2326
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
2427
```js
2528
{
2629
"dependencies": {
27-
"com.gameframe.gui": "https://github.com/coryleach/UnityGUI.git#1.1.3",
30+
"com.gameframe.gui": "https://github.com/coryleach/UnityGUI.git#2.0.0",
2831
...
2932
},
3033
}
3134
```
3235

3336
<!-- DOC-START -->
34-
<!--
37+
<!--
3538
Changes between 'DOC START' and 'DOC END' will not be modified by readme update scripts
3639
-->
3740

Runtime/Attributes/HelpAttribute.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ namespace Gameframe.GUI
1111
[AttributeUsage(AttributeTargets.Field)]
1212
public class HelpAttribute : PropertyAttribute
1313
{
14-
public readonly string text;
15-
public readonly HelpType type;
14+
public string Text { get; }
15+
public HelpType Type { get; }
1616

1717
public HelpAttribute(string text, HelpType type = HelpType.Info)
1818
{
19-
this.text = text;
20-
this.type = type;
19+
Text = text;
20+
Type = type;
2121
}
2222
}
2323

2424
public enum HelpType
2525
{
2626
Info,
2727
Warning,
28-
Error,
28+
Error
2929
}
3030

3131
#if UNITY_EDITOR
@@ -58,7 +58,7 @@ public override float GetPropertyHeight(SerializedProperty prop, GUIContent labe
5858

5959
float minHeight = paddingHeight * 5;
6060

61-
var content = new GUIContent(HelpAttribute.text);
61+
var content = new GUIContent(HelpAttribute.Text);
6262
var style = (GUIStyle)"helpbox";
6363

6464
var height = style.CalcHeight(content, EditorGUIUtility.currentViewWidth);
@@ -87,7 +87,7 @@ public override void OnGUI(Rect position, SerializedProperty prop, GUIContent la
8787
helpPos.height -= addedHeight;
8888
}
8989

90-
EditorGUI.HelpBox(helpPos, HelpAttribute.text, HelpAttribute.type.GetMessageType());
90+
EditorGUI.HelpBox(helpPos, HelpAttribute.Text, HelpAttribute.Type.GetMessageType());
9191

9292
position.y += helpPos.height + marginHeight;
9393
position.height = baseHeight;

Runtime/Camera/CameraDirector.cs

+18-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class CameraDirector : MonoBehaviour
1414
/// Collection to add this camera to on awake
1515
/// </summary>
1616
[SerializeField]
17-
CameraCollection collection = null;
17+
private CameraCollection collection;
1818

1919
/// <summary>
2020
/// Unity events that recieve CameraDirector as an argument
@@ -25,12 +25,8 @@ public class CameraDirectorEvent : UnityEvent<CameraDirector>
2525
}
2626

2727
[SerializeField]
28-
private CameraType cameraType = null;
29-
30-
public CameraType CameraType
31-
{
32-
get { return cameraType; }
33-
}
28+
private CameraType cameraType;
29+
public CameraType CameraType => cameraType;
3430

3531
[SerializeField]
3632
UnityEngine.Camera _camera;
@@ -48,10 +44,16 @@ public UnityEngine.Camera Camera
4844
}
4945
}
5046

51-
public bool canOverwriteExistingCamera = true;
47+
[SerializeField]
48+
private bool canOverwriteExistingCamera = true;
49+
public bool CanOverwriteExistingCamera
50+
{
51+
get => canOverwriteExistingCamera;
52+
set => canOverwriteExistingCamera = value;
53+
}
5254

53-
public CameraDirectorEvent OnDirectorEnabled = new CameraDirectorEvent();
54-
public CameraDirectorEvent OnDirectorDisabled = new CameraDirectorEvent();
55+
public CameraDirectorEvent OnDirectorEnabled { get; } = new CameraDirectorEvent();
56+
public CameraDirectorEvent OnDirectorDisabled { get; } = new CameraDirectorEvent();
5557

5658
protected virtual void Awake()
5759
{
@@ -75,8 +77,12 @@ protected virtual void OnDisable()
7577

7678
protected virtual void OnDestroy()
7779
{
78-
CameraDirector val = null;
79-
if (collection != null && collection.Items.TryGetValue(CameraType, out val))
80+
if (collection == null)
81+
{
82+
return;
83+
}
84+
85+
if (collection.Items.TryGetValue(CameraType, out var val))
8086
{
8187
if (val == this)
8288
{

Runtime/Camera/CameraGyroscopeRotate.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ public class CameraGyroscopeRotate : MonoBehaviour
1919
[SerializeField]
2020
private float smoothTime = 1f;
2121

22-
private float velocityX = 0;
23-
private float velocityY = 0;
24-
private float velocityZ = 0;
22+
private float velocityX;
23+
private float velocityY;
24+
private float velocityZ;
2525

2626
private float delay = 0.5f;
2727

2828
private Vector3 startRotation;
2929

3030
private void Start()
3131
{
32-
startRotation = transform.eulerAngles;
3332
if (!SystemInfo.supportsGyroscope)
3433
{
3534
enabled = false;
3635
return;
3736
}
37+
startRotation = transform.eulerAngles;
3838
}
3939

4040
private void OnEnable()

Runtime/Camera/ObliqueCamera.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@ public class ObliqueCamera : MonoBehaviour
99
{
1010

1111
[SerializeField]
12-
private float horizontal = 0;
12+
private float horizontal;
1313
public float Horizontal
1414
{
1515
get => horizontal;
1616
set => horizontal = value;
1717
}
1818

1919
[SerializeField]
20-
private float vertical = 0;
20+
private float vertical;
2121
public float Vertical
2222
{
2323
get => vertical;
2424
set => vertical = value;
2525
}
2626

27-
public Matrix4x4 matrix;
27+
[SerializeField]
28+
private Matrix4x4 matrix;
2829

2930
private UnityEngine.Camera _myCamera;
3031
public UnityEngine.Camera MyCamera

Runtime/Camera/RuntimeTable.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class RuntimeTable<TKey, TValue> : ScriptableObject
99
private bool allowOverwrite = true;
1010

1111
[SerializeField]
12-
private bool throwExceptions = false;
12+
private bool throwExceptions;
1313

1414
private readonly Dictionary<TKey, TValue> _items = new Dictionary<TKey, TValue>();
1515

Runtime/Camera/Supersample.cs

+10-8
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@ namespace Gameframe.GUI
99
public class Supersample : MonoBehaviour
1010
{
1111

12-
RenderTexture supersampleRenderTexture;
13-
public UnityEngine.Camera cam;
12+
private RenderTexture _supersampleRenderTexture;
13+
14+
[SerializeField]
15+
private UnityEngine.Camera cam;
1416

15-
const float factor = 1.5f;
17+
private const float Factor = 1.5f;
1618

17-
void Start()
19+
private void Start()
1820
{
19-
supersampleRenderTexture = new RenderTexture( Mathf.RoundToInt( Screen.width * factor ), Mathf.RoundToInt( Screen.height * factor ), 24, RenderTextureFormat.ARGB32 );
21+
_supersampleRenderTexture = new RenderTexture( Mathf.RoundToInt( Screen.width * Factor ), Mathf.RoundToInt( Screen.height * Factor ), 24, RenderTextureFormat.ARGB32 );
2022
}
2123

22-
void OnRenderImage( RenderTexture source, RenderTexture destination )
24+
private void OnRenderImage( RenderTexture source, RenderTexture destination )
2325
{
24-
cam.targetTexture = supersampleRenderTexture;
26+
cam.targetTexture = _supersampleRenderTexture;
2527
cam.Render();
2628
cam.targetTexture = null;
2729

28-
Graphics.Blit( supersampleRenderTexture, destination );
30+
Graphics.Blit( _supersampleRenderTexture, destination );
2931
}
3032

3133
}

Runtime/Effects/FadeInText.cs

+11-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Gameframe.GUI
88
public class FadeInText : PlayableTextMeshEffect, ITextMeshColorEffect
99
{
1010
[SerializeField]
11-
private bool smooth = false;
11+
private bool smooth;
1212

1313
protected override void AddToManager(TextMeshEffectTMPro effectManager)
1414
{
@@ -22,20 +22,22 @@ protected override void RemoveFromManager(TextMeshEffectTMPro effectManager)
2222

2323
public void UpdateColorEffect(TMP_CharacterInfo charInfo, ref EffectData data)
2424
{
25-
var left = EaseFunctions.Ease(easeType,1 - Mathf.Clamp01(data.index - (progress - 0.5f)));
26-
data.color0.a = (byte) Mathf.Round(255 * left);
27-
data.color1.a = (byte) Mathf.Round(255 * left);
25+
var left = EaseFunctions.Ease(easeType,1 - Mathf.Clamp01(data.Index - (progress - 0.5f)));
26+
var leftAlpha = (byte) Mathf.Round(255 * left);
27+
data.SetAlpha(0,leftAlpha);
28+
data.SetAlpha(1,leftAlpha);
2829

2930
if (smooth)
3031
{
31-
var right = EaseFunctions.Ease(easeType, 1 - Mathf.Clamp01(data.index - (progress - 1f)));
32-
data.color2.a = (byte) Mathf.Round(255 * right);
33-
data.color3.a = (byte) Mathf.Round(255 * right);
32+
var right = EaseFunctions.Ease(easeType, 1 - Mathf.Clamp01(data.Index - (progress - 1f)));
33+
var rightAlpha = (byte) Mathf.Round(255 * right);
34+
data.SetAlpha(2,rightAlpha);
35+
data.SetAlpha(3,rightAlpha);
3436
}
3537
else
3638
{
37-
data.color2.a = (byte) Mathf.Round(255 * left);
38-
data.color3.a = (byte) Mathf.Round(255 * left);
39+
data.SetAlpha(2,leftAlpha);
40+
data.SetAlpha(3,leftAlpha);
3941
}
4042
}
4143
}

Runtime/Effects/MaterialFloatAnimator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class MaterialFloatAnimator : MonoBehaviour
88
[SerializeField]
99
private Material material;
1010

11-
[SerializeField, Range(0.0f, 10)] private float startValue = 0f;
11+
[SerializeField, Range(0.0f, 10)] private float startValue;
1212
[SerializeField, Range(0.0f, 10)] private float endValue = 5.0f;
1313
[SerializeField, Range(0.1f, 50)] private float animationSpeed = 25;
1414

Runtime/Effects/MoveInText.cs

+4-14
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,20 @@
55
namespace Gameframe.GUI
66
{
77
[RequireComponent(typeof(TextMeshEffectTMPro))]
8-
public class MoveInText : PlayableTextMeshEffect, ITextMeshVertexEffect
8+
public class MoveInText : VertexTextMeshEffect
99
{
1010
[SerializeField]
1111
private Vector3 startOffset = Vector3.zero;
1212

1313
[SerializeField]
1414
protected Vector3 endOffset = Vector3.one;
1515

16-
protected override void AddToManager(TextMeshEffectTMPro effectManager)
16+
public override void UpdateVertexEffect(TMP_CharacterInfo charInfo, ref EffectData data)
1717
{
18-
effectManager.AddVertexEffect(this);
19-
}
20-
21-
protected override void RemoveFromManager(TextMeshEffectTMPro effectManager)
22-
{
23-
effectManager.RemoveVertexEffect(this);
24-
}
25-
26-
public void UpdateVertexEffect(TMP_CharacterInfo charInfo, ref EffectData data)
27-
{
28-
var t = Mathf.Clamp01(progress - data.index);
18+
var t = Mathf.Clamp01(progress - data.Index);
2919
t = EaseFunctions.Ease(easeType, t);
3020
var delta = endOffset - startOffset;
31-
data.localPosition = startOffset + delta * t;
21+
data.LocalPosition = startOffset + delta * t;
3222
}
3323
}
3424
}

Runtime/Effects/PlayableTextMeshEffect.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public abstract class PlayableTextMeshEffect : MonoBehaviour, IPlayableTextMeshE
1111
private TextMeshEffectTMPro effectManager;
1212

1313
[SerializeField]
14-
protected bool playOnEnable = false;
14+
protected bool playOnEnable;
1515

1616
[SerializeField]
1717
protected Easing easeType = Easing.Linear;
@@ -28,9 +28,9 @@ public float CharacterPerSecond
2828
protected UnityEvent onComplete = new UnityEvent();
2929
public UnityEvent OnComplete => onComplete;
3030

31-
protected float progress = 0;
31+
protected float progress;
3232

33-
private Coroutine coroutine = null;
33+
private Coroutine coroutine;
3434

3535
public bool IsPlaying => coroutine != null;
3636

Runtime/Effects/ScaleInText.cs

+4-14
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,20 @@
55
namespace Gameframe.GUI
66
{
77
[RequireComponent(typeof(TextMeshEffectTMPro))]
8-
public class ScaleInText : PlayableTextMeshEffect, ITextMeshVertexEffect
8+
public class ScaleInText : VertexTextMeshEffect
99
{
1010
[SerializeField]
1111
private Vector3 startScale = Vector3.zero;
1212

1313
[SerializeField]
1414
protected Vector3 endScale = Vector3.one;
1515

16-
protected override void AddToManager(TextMeshEffectTMPro effectManager)
16+
public override void UpdateVertexEffect(TMP_CharacterInfo charInfo, ref EffectData data)
1717
{
18-
effectManager.AddVertexEffect(this);
19-
}
20-
21-
protected override void RemoveFromManager(TextMeshEffectTMPro effectManager)
22-
{
23-
effectManager.RemoveVertexEffect(this);
24-
}
25-
26-
public void UpdateVertexEffect(TMP_CharacterInfo charInfo, ref EffectData data)
27-
{
28-
var t = Mathf.Clamp01(progress - data.index);
18+
var t = Mathf.Clamp01(progress - data.Index);
2919
t = EaseFunctions.Ease(easeType, t);
3020
var delta = endScale - startScale;
31-
data.localScale = startScale + delta * t; //Vector3.Lerp(startScale, endScale, t );
21+
data.LocalScale = startScale + delta * t;
3222
}
3323
}
3424
}

0 commit comments

Comments
 (0)