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; | |
public class MinMaxRangeAttribute : Attribute | |
{ | |
public MinMaxRangeAttribute(float min, float max) | |
{ | |
Min = min; | |
Max = max; | |
} |
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 System.Collections.Generic; | |
using UnityEngine; | |
[RequireComponent(typeof(AudioSource))] | |
[RequireComponent(typeof(Collider))] | |
public class CollisionAudio : MonoBehaviour | |
{ | |
[SerializeField] private AudioClip collideSoft; | |
[SerializeField] private AudioClip collideHard; |
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 System.Collections; | |
using UnityEditor; | |
using UnityEngine; | |
[ExecuteInEditMode] | |
public class SimulateGravity : MonoBehaviour | |
{ | |
public bool simulate = false; | |
public bool remove = 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
// put this line in EVERY .cs file that gets that annoying error about a variable always having default value | |
#pragma warning disable 0649 |
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
// this is not a full class, just a code snippet showing the relevant method to convert a Color object | |
// to an RGB hex value so it can be used in a text field | |
public Color playerColor; | |
public Text playerTextField; | |
playerTextField.text = "<color=#" + ColorUtility.ToHtmlStringRGB(playerColor) + ">PLAYER</color>"; |
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
[InlineButton("AutoName", "Auto")] | |
public new string name; | |
public void AutoName() | |
{ | |
#if UNITY_EDITOR | |
string assetPath = UnityEditor.AssetDatabase.GetAssetPath(GetInstanceID()); | |
name = System.IO.Path.GetFileNameWithoutExtension(assetPath); | |
#endif | |
} |
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 ConstantRotation : MonoBehaviour | |
{ | |
public bool randomizeValues; | |
public Vector3 speed = new Vector3(0f, 100f, 0f); | |
public float multiplier = 1; | |
public Vector2 randomMultiplierRange = new Vector2(90f, 120f); | |
void Start() |
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 System.Linq; | |
// Original source: http://answers.unity.com/answers/746039/view.html | |
public class CreateMaterialsForTextures : ScriptableWizard | |
{ | |
[MenuItem("Tools/CreateMaterialsForTextures")] | |
static void CreateMaterials() |
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; | |
public class SnapToGround : Editor | |
{ | |
[MenuItem("Tools/Snap Selection To Ground #END")] | |
public static void SnapToGroundNow() | |
{ | |
foreach (Transform t in Selection.transforms) | |
{ | |
Undo.RegisterCompleteObjectUndo(Selection.transforms, "SnapToGroundNow"); |