This file contains 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
// A simple Unity example script that makes a UI component track position of world space object rendered with | |
// specific world space camera. Canvas needs to be in Screen Space Camera mode. | |
[ExecuteInEditMode] | |
public class UIFollow : MonoBehaviour | |
{ | |
[Tooltip("World space object to follow")] | |
public GameObject target; | |
[Tooltip("World space camera that renders the target")] | |
public Camera worldCamera; | |
[Tooltip("Canvas set in Screen Space Camera mode")] |
This file contains 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; | |
/* Random Utils By Sampsa Lehtonen, sampsa.lehtonen(AT)iki.fi, @snlehton | |
Some of my Random utils created for procedural generation and deterministic randomness. | |
Uses Linear Feedback Shift Register (LFSR) for quick and dirty random. | |
Lacks Perlin noise... need to reimplement the one in Unity in case they go and change the implementation. | |
CAUTION: I haven't verified the distribution of any of these functions, so use at your own risk. The aim has been to have | |
deterministic Unity-implementation-free random functions with features that Unity hasn't offered. |
This file contains 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 UnityEngine.Assertions; | |
// Barebones Singleton class to be used with Unity | |
// Supports also Singleton instances coming from prefabs (PrefabSingleton). | |
// Prefabs need to reside in Resources folder and named [ComponentName].asset. | |
// If you have GameManager class, then you need Resources/GameManager.asset | |
public class Singleton<T> : MonoBehaviour where T:MonoBehaviour | |
{ |
This file contains 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
// Create Dropdown button | |
if (EditorGUI.DropdownButton(position, GUIContent.none, FocusType.Passive)) | |
{ | |
var genericMenu = new GenericMenu(); | |
// List<string> options | |
foreach (var option in options) | |
{ | |
bool selected = option == property.stringValue; | |
genericMenu.AddItem(new GUIContent(options), selected, () => |
OlderNewer