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
// NOTE put in a Editor folder | |
using UnityEngine; | |
using UnityEditor; | |
using System.Collections; | |
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))] | |
public class ReadOnlyPropertyDrawer : PropertyDrawer | |
{ | |
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) |
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; | |
using System; | |
using System.Collections; | |
public class SineSynth : MonoBehaviour | |
{ | |
[Range(100,1000)] | |
public double Frequency = 440; | |
[Range(0.05f, 0.3f)] | |
public double Gain = 0.05; // Amplitude? |
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; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
public static class TransformExtentions | |
{ | |
public static Transform FindInChildren(this Transform t, string name) | |
{ | |
// Heres a smart linq version. i dont like it. |
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; | |
public class SpriteImporter : AssetPostprocessor // AssetPostprocessor gives us a bunch of tools we can use to modifiy assets on import | |
{ | |
// This hooks in to texture Preprocessing. that means it happens *before* the texture is processed by unity so we can fiddle with its import settings! | |
// This method will be run on ever asset as it is imported. For example, whenever a new png file is added to the project or if you right click -> reimport on a texture asset. | |
void OnPreprocessTexture() | |
{ | |
//if (assetPath.Contains("UI") || assetPath.Contains("Sprite")) // Optional filtering. We can set it to only effect files with certain keywords in the path. Uncomment if useful | |
{ |
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
In PlayerScript: | |
// Sprite direction | |
if (xInput > 0) { | |
transform.rotation = Quaternion.Euler (0, 0, 0); | |
} else if (xInput < 0) { | |
transform.rotation = Quaternion.Euler (0, 180, 0); | |
} | |
// Aiming |
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 Random random; <- put this in one of your class files (Usually Xna has a Game class? probably that one | |
random = new Random(); <-- In the same file put this somewhere. Xna games tend to have a LoadContent or a Initialize method? that would be a good place. This creates and instance of the Random class. Random is an object that has lots of methods for giving you differnt types of random numbers, like the name suggests! :) | |
var item = myList[random.Next(myList.count)]; <- WHen you want to get the random item. the Next method on Random makes it generate the next random number. Passing in the length/count of the items in your list makes it generate a number thats between 0 and that number. |
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 class Degub | |
{ | |
public static void Log(object message) | |
{ | |
Debug.Log(message); | |
} | |
public static void Log(object message, Object context) | |
{ | |
Debug.Log(message, context); |
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 System.Runtime.InteropServices; | |
using UnityEngine; | |
using UnityColor32 = UnityEngine.Color32; | |
[Serializable] | |
[StructLayout(LayoutKind.Explicit)] // Tell .net that we know exactly where we want these values | |
public struct Color32 | |
{ | |
[FieldOffset(0)] |
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; | |
using System.Collections; | |
public class APIExamples : MonoBehaviour | |
{ | |
public int randomColorCount = 5; | |
public Color[] RandomBrightColors; | |
public Color[] RandomPastelColors; | |
public Color[] RandomDarkColors; |
NewerOlder