Skip to content

Commit 66419fc

Browse files
committed
New architeture, GameObject Utils added ,Transform2D Removed
1 parent df43334 commit 66419fc

13 files changed

+136
-58
lines changed

Assets/Unity Extended/Scripts/Utils/IListExtensions.cs renamed to Assets/Unity Extended/Scripts/Extensions/Native/IListExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Generic;
22
using UnityEngine;
33

4-
namespace UnityExtended.Utils
4+
namespace UnityExtended.Extensions.Native
55
{
66
public static class IListExtensions
77
{

Assets/Unity Extended/Scripts/Extensions/RigidBody2DExtensions.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

Assets/Unity Extended/Scripts/Extensions/Transform2DExtensions.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using UnityEngine;
2+
3+
namespace UnityExtended.Extensions.Unity
4+
{
5+
public static class AnimatorExtensions
6+
{
7+
public static void SetRandomParameter(this Animator anim,string name,int variations)
8+
{
9+
if(variations <= 0) throw new System.Exception("Variations cannot be 0 or less");
10+
if(name == null) throw new System.ArgumentNullException("Name param cannot be null");
11+
12+
anim.SetInteger(name,Random.Range(0,variations+1));
13+
}
14+
}
15+
}

Assets/Unity Extended/Scripts/Extensions/GameObjectExtensions.cs renamed to Assets/Unity Extended/Scripts/Extensions/Unity/GameObjectExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Generic;
22
using UnityEngine;
33

4-
namespace UnityExtended.Extensions
4+
namespace UnityExtended.Extensions.Unity
55
{
66
public static class GameObjectExtensions
77
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using UnityEngine;
2+
3+
namespace UnityExtended.Extensions.Unity
4+
{
5+
public static class Rigidbody2DExtension
6+
{
7+
8+
}
9+
}

Assets/Unity Extended/Scripts/Extensions/SpriteRendererExtension.cs renamed to Assets/Unity Extended/Scripts/Extensions/Unity/SpriteRendererExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using UnityEngine;
22

3-
namespace UnityExtended.Extensions
3+
namespace UnityExtended.Extensions.Unity
44
{
55
public static class SpriteRendererExtension
66
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using UnityEngine;
2+
3+
namespace UnityExtended.Extensions.Unity
4+
{
5+
public static class Transform2DExtension
6+
{
7+
8+
}
9+
}

Assets/Unity Extended/Scripts/Extensions/Vector2Extensions.cs renamed to Assets/Unity Extended/Scripts/Extensions/Unity/Vector2Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using UnityEngine;
33

4-
namespace UnityExtended.Extensions
4+
namespace UnityExtended.Extensions.Unity
55
{
66
public static class Vector2Extension
77
{
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using UnityEngine;
3+
4+
namespace UnityExtended.Extensions.Unity
5+
{
6+
public static class Vector3Extension
7+
{
8+
public static Vector3 ToAbsolute(this Vector3 vector3)
9+
{
10+
int x = Convert.ToInt32(Math.Abs(vector3.x));
11+
int y = Convert.ToInt32(Math.Abs(vector3.y));
12+
int z = Convert.ToInt32(Math.Abs(vector3.z));
13+
return new Vector3(x, y,z);
14+
}
15+
16+
public static void FromAngle(this Vector3 vector3, int angle)
17+
{
18+
float angleRad = angle * (Mathf.PI / 180f);
19+
vector3.x = Mathf.Cos(angleRad);
20+
vector3.y = Mathf.Sin(angleRad);
21+
}
22+
23+
/// <summary>
24+
/// Return the absolute angle of the target vector2
25+
/// </summary>
26+
/// <param name="vector2"></param>
27+
/// <param name="target"></param>
28+
/// <returns>The angle torwards target</returns>
29+
public static float GetAngle(this Vector3 vector3, Vector3 target)
30+
{
31+
var direction = target - vector3;
32+
return direction.ToAngle();
33+
}
34+
35+
/// <summary>
36+
/// Converts the current Vector 2 to angle
37+
/// </summary>
38+
/// <param name="vector2"></param>
39+
/// <returns></returns>
40+
public static float ToAngle(this Vector3 vector3)
41+
{
42+
float angle = Mathf.Atan2(vector3.y, vector3.x) * Mathf.Rad2Deg;
43+
if (angle < 0) angle += 360;
44+
45+
return angle;
46+
}
47+
48+
}
49+
}

0 commit comments

Comments
 (0)