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
| [InitializeOnLoad] | |
| public static class OnOpenUnityEditorExample { | |
| const string lastCompileTimeKey = "InkIntegrationLastCompileTime"; | |
| static InkEditorUtils () { | |
| float lastCompileTime = LoadAndSaveLastCompileTime(); | |
| if(EditorApplication.timeSinceStartup < lastCompileTime) | |
| OnOpenUnityEditor(); | |
| } | |
| static void OnOpenUnityEditor () { |
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.Linq; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using UnityEngine.UI; | |
| using UnityEngine.EventSystems; | |
| // Handles moving, scaling and rotating UI objects using multitouch. | |
| // Should be just about 1-1, as you'd expect on a touch screen, although because it applies deltas there's a bit of "slippage" if you manipulate the same object for a while/rapidly. | |
| // To test multitouch with a mouse editor you can comment out the marked line in OnEndDrag. | |
| public class MultitouchDraggable : Selectable, IBeginDragHandler, IEndDragHandler, IDragHandler { |
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
| // Example usage - | |
| // LoadableSprite loadableSprite = new LoadableSprite ("texture"); | |
| // loadableSprite.LoadAsync (loadedSprite => { | |
| // Do stuff on load here! | |
| // }) | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| // You'll need to put this in your scene somewhere so the LoadableSprite class can use coroutines. |
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.Generic; | |
| using UnityEngine; | |
| [ExecuteAlways] | |
| public static class ColorDescriptor { | |
| public static string GetNameForColor (Color color) { | |
| var bestDist = float.MaxValue; | |
| string best = null; | |
| foreach(var colorName in colorNames) { |
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
| Select:End="5" RelativeTo="ProjectStart" Start="0" Track="0" TrackCount="1" | |
| Delete: | |
| Select:End="5" RelativeTo="ProjectEnd" Start="0" Track="0" TrackCount="1" | |
| Delete: |
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
| Select:End="100000" RelativeTo="Project" Start="40" Track="0" TrackCount="1" | |
| Delete: | |
| Select:End="2" RelativeTo="ProjectEnd" Start="0" | |
| Copy: | |
| SelectNone: | |
| Paste: | |
| SelectTracks:Mode="Set" Track="0" TrackCount="2" | |
| CrossfadeTracks:curve="0" direction="Automatic" type="ConstantGain" | |
| MixAndRender: | |
| SelectNone: |
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
| // Add this to convert a local position to an anchored position | |
| public static Vector2 GetLocalToAnchoredPositionOffset(this RectTransform rectTransform) { | |
| var parentRT = (RectTransform) rectTransform.parent; | |
| var pivotAnchor = new Vector2(Mathf.LerpUnclamped(rectTransform.anchorMin.x, rectTransform.anchorMax.x, rectTransform.pivot.x), Mathf.LerpUnclamped(rectTransform.anchorMin.y, rectTransform.anchorMax.y, rectTransform.pivot.y)); | |
| return -parentRT.rect.size * (pivotAnchor - parentRT.pivot); | |
| } | |
| // Add this to convert a local position to an anchored position | |
| public static Vector2 GetAnchoredToLocalPositionOffset(this RectTransform rectTransform) { | |
| return -rectTransform.GetLocalToAnchoredPositionOffset(); |
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.IO; | |
| using UnityEditor; | |
| using UnityEditor.Presets; | |
| using System.Linq; | |
| // This script automatically applies Presets to assets when they are imported into a folder containing a Preset. | |
| // It also adds any labels on the Preset file to the asset. | |
| public class PresetImportPerFolder : AssetPostprocessor { | |
| void OnPreprocessAsset() { | |
| // Make sure we are applying presets the first time an asset is imported. |
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
| // Usage example: | |
| // using System.Collections.Generic; | |
| // using System.Text.RegularExpressions; | |
| // public enum AudioCategory { | |
| // Undefined, | |
| // Music, | |
| // Narration, | |
| // } |
OlderNewer