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 Logger | |
| { | |
| string header; | |
| public bool enabled = true; | |
| public Logger(string name, string color) | |
| { | |
| header = $"<color={color}>{name}:</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
| using UnityEditor; | |
| using UnityEngine; | |
| public class CleanupMissingScriptsHelper | |
| { | |
| [MenuItem("Assets/Cleanup Missing Scripts")] | |
| private static void CleanupMissingScripts() | |
| { | |
| foreach (var i in Selection.gameObjects) | |
| { |
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 USE_HDRP | |
| public partial class SomeBehaviour : MonoBehaviour | |
| { | |
| partial public void SomeMethod() { | |
| } | |
| } | |
| #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 Unity.Collections; | |
| using Unity.Entities; | |
| using Unity.Jobs; | |
| namespace PatternsOfDots | |
| { | |
| /// <summary> | |
| /// Add a WaitForSeconds component to your entity with a delay parameter. | |
| /// The ScheduleSystem will then wait that many seconds before removing | |
| /// the component, and add a Ready tag component. You can then process |
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
| public static Mesh Extract(Mesh m, int meshIndex) | |
| { | |
| var vertices = m.vertices; | |
| var normals = m.normals; | |
| var newVerts = new List<Vector3>(); | |
| var newNorms = new List<Vector3>(); | |
| var newTris = new List<int>(); | |
| var triangles = m.GetTriangles(meshIndex); | |
| for (var i = 0; i < triangles.Length; i += 3) |
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
| public class AI | |
| { | |
| Domain CreateDomain() | |
| { | |
| using (domain = Domain.New()) | |
| { | |
| worldState = DefineWorldState(health, fuel, speed, angularSpeed); | |
| DefinePrimitiveTask(SetRandomDestination); | |
| DefinePrimitiveTask(MoveToDestination) |
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; | |
| using UnityEngine; | |
| using UnityEngine.Rendering.PostProcessing; | |
| [Serializable] | |
| [PostProcess(typeof(ColorBlindCorrectionRenderer), PostProcessEvent.AfterStack, "Custom/ColorBlindCorrection")] | |
| public sealed class ColorBlindCorrection : PostProcessEffectSettings | |
| { | |
| [Header("1:Protanopia 2:Deuteranopia 3:Tritanopia")] | |
| [Range(0, 2)] |
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
| public class InstanceTracker<T> : MonoBehaviour where T : MonoBehaviour | |
| { | |
| public static List<T> Instances { get; private set; } = new List<T>(); | |
| int instanceIndex = 0; | |
| void OnEnable() | |
| { | |
| instanceIndex = Instances.Count; | |
| Instances.Add(this as T); | |
| } |
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
| public class AddThingToSomeScriptableObject : ScriptableWizard | |
| { | |
| internal SomeScriptableObject someScriptableObject; | |
| public SomeThing someThing; | |
| void OnCreateButton() | |
| { | |
| //add someThing to someScriptableObject. | |
| } | |
| } |
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
| public class InstancedRenderer : System.IDisposable | |
| { | |
| const int BATCH_MAX = 1023; | |
| public NativeArray<Matrix4x4> matrices; | |
| public readonly int count, allocated; | |
| public readonly Mesh mesh; | |
| public readonly Material material; | |
| Matrix4x4[] batchedMatrices = new Matrix4x4[BATCH_MAX]; |