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 System.Collections; | |
public class SOExample : ScriptableObject | |
{ | |
public string text; | |
} |
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 System.Collections; | |
public class SOExampleBehaviour : MonoBehaviour | |
{ | |
public SOExample test; | |
public void OnEnable() | |
{ | |
// instantiate if needed | |
if (test == null) | |
test = ScriptableObject.CreateInstance<SOExample>(); |
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
.... | |
--- !u!114 &819407913 <<--- this is our ScriptableObject id in the scene | |
MonoBehaviour: | |
m_ObjectHideFlags: 0 | |
m_PrefabParentObject: {fileID: 0} | |
m_PrefabInternal: {fileID: 0} | |
m_GameObject: {fileID: 0} | |
m_Enabled: 1 | |
m_EditorHideFlags: 0 | |
m_Script: {fileID: 11500000, guid: 4a48e9db79a952f419ca79d71a03fe31, type: 3} |
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 System.Collections; | |
[ExecuteInEditMode] | |
public class SOExampleBehaviour : MonoBehaviour | |
{ | |
public SOExample test; | |
public void OnEnable() | |
{ | |
// find existing instance if needed | |
if (test == null) |
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
public static class RemoveEmptyDirectories | |
{ | |
[MenuItem("Tools/EditorHacks/Remove empty directories...")] | |
public static void MenuItem_RemoveEmptyDirectories() | |
{ | |
RemoveEmptyDirectoriesRecursive("Assets/"); | |
} | |
private static void RemoveEmptyDirectoriesRecursive(string path) | |
{ |
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; | |
// Render the screen in lower resolution | |
[ExecuteInEditMode] | |
[RequireComponent(typeof(Camera))] | |
public class ResoScaler : MonoBehaviour | |
{ | |
[Range(1, 8)] | |
public float scale = 1; |
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 System.Collections.Generic; | |
public static class ListExtensions | |
{ | |
public static T GetRandomWeighted<T>(this List<T> list, Func<T, float> selector) | |
{ | |
T selected = default(T); | |
float totalWeight = 0; | |
foreach (var item in list) | |
{ |
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; | |
public class SpawnTest : MonoBehaviour | |
{ | |
// a prefab containing SpawnTestPrefab | |
public GameObject prefab; | |
void Start() | |
{ | |
Instantiate(prefab, new Vector3(100, 0, 0), Quaternion.identity); |
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 System.Collections; | |
using System.Collections.Generic; | |
using System; | |
/* | |
Simple EventManager class to implement one-to-many event passing. Features: | |
* Simple enum and payload events. | |
* Delayed event sending (send later in the frame in one place). | |
* Detects adding duplicates/removing non-existent listeners in Unity editor mode. |
OlderNewer