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
| // UnityElementInitialization.cs | |
| // | |
| using System; | |
| using UnityEngine; | |
| // In Unity, new struct or class elements in a serialized list do not | |
| // get a chance to run static initializers or constructors. All members | |
| // are given their default(T) values instead. This is an example of how | |
| // to use the OnValidate() method to support initialization. |
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
| // UnityColorUtilities.cs | |
| // | |
| using UnityEngine; | |
| public static class ColorUtilities | |
| { | |
| public static Color HexRGB(uint hexcode) | |
| { | |
| // e.g., 0xFF0033 | |
| float b = (hexcode & 0xFF) / 255f; |
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
| // FuzzTable.cs | |
| // | |
| using System; | |
| using System.IO; | |
| using System.Collections.Generic; | |
| using System.Text.RegularExpressions; | |
| // A simple random string picking engine. | |
| // | |
| // Load it up like a list with string choices that can be picked from. |
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
| // SelectionOutlinePreference.cs | |
| // | |
| using System; | |
| using System.Reflection; | |
| using UnityEngine; | |
| using UnityEditor; | |
| // Adds menu items to toggle the Unity Editor tab's outlining of the selected objects. | |
| // Helpful when trying to preview the look of particle systems or other alpha-edged objects. | |
| // |
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 the effective scale of a BoxCollider ends up making the .size negative, | |
| // such as when a prefab is scaled (-1,+1,+1), then Unity complains loudly: | |
| // | |
| // /!\ BoxColliders does not support negative scale or size. | |
| // | |
| // This works around the problem by looking at the signs of the lossy scale, | |
| // and flipping the same signs in the box collider's size vector. Since | |
| // the box collider is always aligned with the local matrix, this has no | |
| // effect on the collider except to quiet the console warnings. |
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
| // UnityWaitToStartBehaviour.cs | |
| // | |
| using UnityEngine; | |
| // The magical Start() method can also be treated as a coroutine if it returns | |
| // IEnumerator. This lets a component class behave linearly, or at least start | |
| // up with linear logic such as waiting for the right conditions to begin the | |
| // Update() loop. | |
| public class WaitToStartBehaviour: 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
| // Unity LayerMask is castable to a 32bit int bit field. | |
| // Add some extension methods to make it easier and more readable to | |
| // determine if a given layer or object is within the bits of a mask. | |
| public static bool Contains(this LayerMask mask, int layer) | |
| { | |
| return (0 != (mask & (1 << layer))); | |
| } | |
| public static bool Contains(this LayerMask mask, GameObject gob) |
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
| // Unity C# extension methods to the Transform class. | |
| // Transform already has TransformPosition/InverseTransformPosition. | |
| // Add the correct Quaternion terms to apply or find a relative rotation. | |
| public static Quaternion TransformRotation(this Transform transform, | |
| Quaternion localRotation) | |
| { | |
| return transform.rotation * localRotation; | |
| } |
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
| # -*- python -*- | |
| ''' | |
| SYNOPSIS | |
| >>> import weighted | |
| >>> choices = { 'heads': 2, 'tails': 1 } | |
| >>> for i in xrange(100): |
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 void DrawPolygon(Vector3 center, Vector3 axis, float radius, | |
| int sides, Color color=default, float duration=0f, bool depthTest=true) | |
| { | |
| //duration = Mathf.Max(0.001f, duration); | |
| Vector3 start = Limb(axis); | |
| Vector3 prior = start * radius; | |
| if (sides < 3) sides = 3; | |
| float step = 360f/sides; | |
| for (float f = step; f <= 360f; f += step) |
NewerOlder