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 Ballistic : MonoBehaviour | |
{ | |
public Vector3 velocity; | |
void Update () | |
{ | |
velocity += Physics.gravity * Time.deltaTime; |
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; | |
public class MyScript : MonoBehaviour | |
{ | |
// Always call this to create MyScript objects so we know they are complete. | |
// Never use AddComponent<MyScript>() outside of this class. | |
public static MyScript Create( | |
string resourcesPath, |
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; | |
public class TTL : MonoBehaviour | |
{ | |
public float AgeLimit; | |
float age; | |
public System.Action<GameObject> Callback; |
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; | |
// @kurtdekker | |
// Make sure this is in an Editor folder! | |
public static class DuplicationHelpers | |
{ | |
// duplicates the current object and puts it back right after the original. | |
[MenuItem( "Assets/Dupe Here FFS")] |
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
// Originally from: | |
// http://forum.unity3d.com/threads/script-simple-script-that-automatically-adjust-anchor-to-gui-object-size-rect-transform.269690/ | |
#if UNITY_EDITOR | |
using UnityEditor; | |
using UnityEngine; | |
using System.Collections; | |
public class AnchorExtensions : MonoBehaviour { |
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; | |
// @kurtdekker | |
// | |
// This is to take any continuous quantity and change it from one value | |
// to another over time. This code is for floats. It can be adapted to work for: | |
// | |
// Vector2, Vector3, Vector3 |
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; | |
// by @kurtdekker - handy example of simple persistent settings. | |
// | |
// To use, just use the variables like any other: | |
// | |
// SETTINGS.VolumeLevel = 1.0f; | |
// |
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; | |
// by @kurtdekker - to make a Unity singleton that has some | |
// prefab-stored, data associated with it, eg a music manager | |
// | |
// To use: access with SingletonViaPrefab.Instance | |
// | |
// To set up: |
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; | |
// by @kurtdekker - to make a simple Unity singleton that has no | |
// predefined data associated with it, eg, a high score manager. | |
// | |
// To use: access with SingletonSimple.Instance | |
// | |
// To set up: |
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
// From: https://answers.unity.com/questions/801928/46-ui-making-a-button-transparent.html?childToView=851816 | |
// | |
// @kurtdekker | |
// | |
// Touchable invisible non-drawing Graphic (usable with Buttons too): | |
// | |
// To make an invisible Button: | |
// | |
// 1. make a Button in the normal way | |
// 2. delete the "Text" GameObject which comes below a Button as standard |