This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class RandomiseInsideCollider : MonoBehaviour | |
{ | |
public Collider2D AreaPolygonCollider; | |
Bounds Bounds; | |
Vector3 BoundX1, BoundX2, BoundY1, BoundY2; | |
Vector3 randomPos; | |
public Transform go; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
// Taken from: https://answers.unity.com/questions/118306/grouping-objects-in-the-hierarchy.html | |
public static class GroupCommand | |
{ | |
[MenuItem("GameObject/Group Selected %g")] | |
private static void GroupSelected() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
// Taken from: https://stackoverflow.com/questions/39380901/shake-an-object-back-and-forth-with-easing-at-the-end | |
public class ObjectShaker : MonoBehaviour | |
{ | |
public GameObject GameObjectToShake; | |
bool shaking = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
using UnityEditor.SceneManagement; | |
// inspired by https://answers.unity.com/questions/205742/adding-scene-to-build.html?_ga=2.184209894.1575122923.1603913761-831749454.1600446627 | |
public static class AddSceneToBuildSettingsShortcut | |
{ | |
[MenuItem("Game/Add scene as last build scene &a")] | |
private static void AddAsLastBuildScene() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using UnityEngine; | |
using UnityEditor; | |
[InitializeOnLoad] | |
public static class NewObjectBottomOfHierarchy | |
{ | |
static NewObjectBottomOfHierarchy() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using UnityEditor.EditorTools; | |
[EditorTool("Prefab Painter 2D")] | |
public class PrefabPainter2D : EditorTool | |
{ | |
float DiscRadius; | |
public override void OnToolGUI(EditorWindow window) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SciptableObjectValueSetter { | |
// 'Mechanic' is a ScriptableObject | |
var so = (Mechanic)AssetDatabase.LoadAssetAtPath("Assets/SOs/Abilities.asset", typeof(Mechanic)); | |
so.SomeValue = "boop"; | |
// And this ensures that the value is saved not only in the inspector and also survives all kinds of reloads! | |
EditorUtility.SetDirty(so); | |
AssetDatabase.SaveAssets(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using UnityEditor; | |
using UnityEngine; | |
using UnityEditor.SceneManagement; | |
[InitializeOnLoad] | |
public class SceneNameDisplay | |
{ | |
[MenuItem("Tools/Scene name toggle &r")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// taken from: https://forum.unity.com/threads/change-gameobject-layer-at-run-time-wont-apply-to-child.10091/ | |
// special thanks to: chadfranklin47 | |
public static class ExtensionMethods | |
{ | |
public static void SetLayerRecursively(this Transform parent, int layer) | |
{ | |
parent.gameObject.layer = layer; | |
for (int i = 0, count = parent.childCount; i < count; i++) |