Skip to content

Commit 53ce36d

Browse files
committed
initial commit
0 parents  commit 53ce36d

Some content is hidden

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

51 files changed

+1143
-0
lines changed

.gitignore

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This .gitignore file should be placed at the root of your Unity project directory
2+
#
3+
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
4+
#
5+
/[Ll]ibrary/
6+
/[Tt]emp/
7+
/[Oo]bj/
8+
/[Bb]uild/
9+
/[Bb]uilds/
10+
/[Ll]ogs/
11+
/[Uu]ser[Ss]ettings/
12+
13+
# MemoryCaptures can get excessive in size.
14+
# They also could contain extremely sensitive data
15+
/[Mm]emoryCaptures/
16+
17+
# Recordings can get excessive in size
18+
/[Rr]ecordings/
19+
20+
# Uncomment this line if you wish to ignore the asset store tools plugin
21+
# /[Aa]ssets/AssetStoreTools*
22+
23+
# Autogenerated Jetbrains Rider plugin
24+
/[Aa]ssets/Plugins/Editor/JetBrains*
25+
26+
# Visual Studio cache directory
27+
.vs/
28+
29+
# Gradle cache directory
30+
.gradle/
31+
32+
# Autogenerated VS/MD/Consulo solution and project files
33+
ExportedObj/
34+
.consulo/
35+
*.csproj
36+
*.unityproj
37+
*.sln
38+
*.suo
39+
*.tmp
40+
*.user
41+
*.userprefs
42+
*.pidb
43+
*.booproj
44+
*.svd
45+
*.pdb
46+
*.mdb
47+
*.opendb
48+
*.VC.db
49+
50+
# Unity3D generated meta files
51+
*.pidb.meta
52+
*.pdb.meta
53+
*.mdb.meta
54+
55+
# Unity3D generated file on crash reports
56+
sysinfo.txt
57+
58+
# Builds
59+
*.apk
60+
*.aab
61+
*.unitypackage
62+
*.app
63+
64+
# Crashlytics generated file
65+
crashlytics-build.properties
66+
67+
# Packed Addressables
68+
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
69+
70+
# Temporary auto-generated Android Assets
71+
/[Aa]ssets/[Ss]treamingAssets/aa.meta
72+
/[Aa]ssets/[Ss]treamingAssets/aa/*

Core.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Components.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Components/CollisionEmitter.cs

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
3+
using UnityEngine;
4+
5+
namespace UnityExtensions
6+
{
7+
public class CollisionEmitter : MonoBehaviour
8+
{
9+
public Collider[] Colliders => GetComponents<Collider>();
10+
11+
public event EventHandler<Collision> OnEnter;
12+
13+
public event EventHandler<Collision> OnStay;
14+
15+
public event EventHandler<Collision> OnExit;
16+
17+
public event EventHandler<Collider> OnTrigEnter;
18+
19+
public event EventHandler<Collider> OnTrigStay;
20+
21+
public event EventHandler<Collider> OnTrigExit;
22+
23+
private void OnCollisionEnter(Collision collision)
24+
{
25+
OnEnter?.Invoke(this, collision);
26+
}
27+
28+
private void OnCollisionStay(Collision collision)
29+
{
30+
OnStay?.Invoke(this, collision);
31+
}
32+
33+
private void OnCollisionExit(Collision collision)
34+
{
35+
OnExit?.Invoke(this, collision);
36+
}
37+
38+
private void OnTriggerEnter(Collider other)
39+
{
40+
OnTrigEnter?.Invoke(this, other);
41+
}
42+
43+
private void OnTriggerStay(Collider other)
44+
{
45+
OnTrigStay?.Invoke(this, other);
46+
}
47+
48+
private void OnTriggerExit(Collider other)
49+
{
50+
OnTrigExit?.Invoke(this, other);
51+
}
52+
}
53+
}

Core/Components/CollisionEmitter.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Components/DontDestroyOnLoad.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace UnityEngine
2+
{
3+
public class DontDestroyOnLoad : MonoBehaviour
4+
{
5+
public Object Target;
6+
7+
private void Awake()
8+
{
9+
DontDestroyOnLoad(Target != null ? Target : gameObject);
10+
}
11+
}
12+
}

Core/Components/DontDestroyOnLoad.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Components/Singleton.cs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
namespace UnityEngine
2+
{
3+
//https://bitbucket.org/EngiGamesBitbucket/howtomakethatgame/src/master/Canvas%20Manager/Singleton.cs
4+
public abstract class Singleton<T> : MonoBehaviour where T : Component
5+
{
6+
private static T instance;
7+
8+
private static bool m_applicationIsQuitting = false;
9+
10+
public static T Instance
11+
{
12+
get
13+
{
14+
if (m_applicationIsQuitting) { return null; }
15+
16+
if (instance == null)
17+
{
18+
instance = FindObjectOfType<T>();
19+
if (instance == null)
20+
{
21+
GameObject obj = new GameObject()
22+
{
23+
name = typeof(T).Name
24+
};
25+
instance = obj.AddComponent<T>();
26+
}
27+
}
28+
return instance;
29+
}
30+
}
31+
32+
///<summary>
33+
///When overriding this, be sure to call the base implementation of this method --> base.Awake();
34+
///IMPORTANT!!! To use Awake in a derived class you need to do it this way
35+
///protected override void Awake()
36+
///{
37+
/// base.Awake();
38+
/// //Your code goes here
39+
///}
40+
///</summary>
41+
protected virtual void Awake()
42+
{
43+
if (instance == null)
44+
{
45+
instance = this as T;
46+
//DontDestroyOnLoad(gameObject);
47+
}
48+
else if (instance != this as T)
49+
{
50+
Destroy(gameObject);
51+
}
52+
else
53+
{
54+
//DontDestroyOnLoad(gameObject);
55+
}
56+
}
57+
58+
private void OnDestroy()
59+
{
60+
if (instance == this)
61+
{
62+
instance = null;
63+
}
64+
}
65+
66+
private void OnApplicationQuit()
67+
{
68+
m_applicationIsQuitting = true;
69+
}
70+
}
71+
}

Core/Components/Singleton.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Extensions.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace UnityEngine
2+
{
3+
public static class LayerMaskExtensions
4+
{
5+
/// <summary>
6+
/// Extension method to check if a layer is in a layermask
7+
/// </summary>
8+
/// <param name="mask"></param>
9+
/// <param name="layer"></param>
10+
/// <returns></returns>
11+
public static bool Contains(this LayerMask mask, int layer)
12+
{
13+
return mask == (mask | (1 << layer));
14+
}
15+
}
16+
}

Core/Extensions/LayerMaskExtensions.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace UnityEngine
4+
{
5+
public static class MonoBehaviourExtensions
6+
{
7+
public static void LogEvent(this MonoBehaviour behaviour, Type caller, string eventName, string message = null)
8+
{
9+
string msg = string.IsNullOrWhiteSpace(message) ? "" : ": " + message;
10+
Debug.LogFormat("{0}: [{4}] called on {1}'s {2} at {3}{5}",
11+
Time.frameCount,
12+
behaviour.name,
13+
caller.GetType().Name,
14+
Time.time,
15+
eventName,
16+
msg);
17+
}
18+
}
19+
}

Core/Extensions/MonoBehaviourExtensions.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Core/Extensions/PhysicsExtensions.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace UnityEngine
2+
{
3+
public static class PhysicsExtensions
4+
{
5+
public static Vector3 CalculateForce(this Rigidbody rigidbody, Vector3 force, ForceMode forceMode)
6+
{
7+
return CalculateForce(force, rigidbody.mass, forceMode);
8+
}
9+
10+
public static Vector3 CalculateForce(Vector3 force, float mass, ForceMode forceMode)
11+
{
12+
switch (forceMode)
13+
{
14+
case ForceMode.Force:
15+
return force * mass * Time.fixedDeltaTime;
16+
17+
case ForceMode.Acceleration:
18+
return force * Time.fixedDeltaTime;
19+
20+
case ForceMode.Impulse:
21+
return force * mass;
22+
23+
case ForceMode.VelocityChange:
24+
return force;
25+
}
26+
return Vector3.zero;
27+
}
28+
}
29+
}

Core/Extensions/PhysicsExtensions.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)