attributeDefinition
struct Definition
??? Why does this work ???

Scriptable Object

m

Editor

EditorUtility

// Create Project Objects/Components

EditorGUI

GUILayout

// buttons

(preview)

AssetPreview

(func)

Texture

GenerateIcon(GameObject previewObject){ ... }

private Texture previewIcon;

previewObject.SetActive(true);

// ARGH! Must set to active to activate thumbnail

previewIcon = AssetPreview.GetAssetPreview (previewObject);

return

previewIcon;

PreviewRenderUtility

(func)

Texture

DrawRenderPreview (Rect r, GameObject previewObject ) { ... }

var mPrevRender = new PreviewRenderUtility();

Asset

(AudioEvent)

(Attribute)

MinMaxRangeAttribute.cs

public

class

MinMaxRangeAttribute : Attribute { ... }

(func)

public

MinMaxRangeAttribute(float min, float max) { ... }

Min = min;

Max = max;

float

Min { get; private set; }

Max { get; private set; }

RangedFloat.cs

public

struct

(attribute)

[Serializable]

RangedFloat { ... }

public

float

minValue;

maxValue;

(ScriptableObject)

AudioEvent.cs

public

abstract

class

AudioEvent : ScriptableObject { ... }

(func)

public

abstract

void

Play(AudioSource source);

SimpleAudioEvent.cs

public

class

(attribute)

[CreateAssetMenu(menuName="Audio Events/Simple")]

SimpleAudioEvent : AudioEvent { ... }

(var)

public

AudioClip[]

clips;

[MinMaxRange(0, 2)]

RangedFloat

pitch;

volume;

(func)

public

override

void

Play(AudioSource source) { ... }

if (clips.Length == 0) return;

(config source)

source.Play();

/Editor

AudioEventEditor.cs

using

UnityEditor;

(class)

(attribute)

[CustomEditor(typeof(AudioEvent), true)]

// ??? true == ???

public

class

AudioEventEditor : Editor { ... }

(var)

private

AudioSource

_previewer;

(func)

public

void

OnEnable() { ... }

_previewer = EditorUtility.CreateGameObjectWithHideFlags("Audio preview", HideFlags.HideAndDontSave, typeof(AudioSource)).GetComponent<AudioSource>();

OnDisable() { ... }

DestroyImmediate(_previewer.gameObject);

override

void

OnInspectorGUI() { ... }

DrawDefaultInspector();

if (GUILayout.Button("Preview")) { ... }

// If statement creates button !

((AudioEvent) target).Play(_previewer);

// if Preview Button pressed, play audio

(Coroutine)

(ScriptableObject)

DestructionSequence.cs

public

abstract

class

DestructionSequence : ScriptableObject { ... }

(func)

public

abstract

IEnumerator

SequenceCoroutine(MonoBehaviour runner);

HideBehindEffect.cs

public

class

(attribute)

[CreateAssetMenu(menuName="Destruction/Hide Behind Effect")]

HideBehindEffect : DestructionSequence { ... }

(var)

public

GameObject

Effect;

float

DestroyOriginalAfterTime = 1f;

(func)

public

override

IEnumerator

SequenceCoroutine(MonoBehaviour runner) { ... }

Instantiate(Effect, runner.transform.position, runner.transform.rotation);

yield return new WaitForSeconds(DestroyOriginalAfterTime);

Destroy(runner.gameObject);

(MonoBehaviour)

Destructible.cs

public

class

Destructible : MonoBehaviour { ... }

(func)

public

void

...

TakeDamage(float damage) { ... }

if (Health < 0 && DestructionSequence) { ... }

StartCoroutine(DestructionSequence.SequenceCoroutine(this));

(Icons)

(ScriptableObject)

AttackPattern.cs

/Editor

AttackShapeEditor.cs

public

class

AttackShapeEditor : Editor { ... }

(var)

(func)

override

public

void

OnInspectorGUI () { ... }

if (Event.current.type == EventType.Layout) { ... }

return;

// What does this do???

bool

(PreviewGUI)

HasPreviewGUI () {...}

return true;

// Ensures Preview Window is displayed in Inspector

// Default == false (off)

OnPreviewGUI (Rect r, GUIStyle background) { ... }

// 2D rect to draw in PreviewGUI window

Texture2D

(Thumbnail)

RenderStaticPreview (string assetPath, Object[] subAssets, int texWidth, int texHeight) { ... }

var staticPreview = new Texture2D (texWidth, texHeight);

(draw)

staticPreview.SetPixel(sx+px, sy+py, col);

staticPreview.Apply();

Unity

(gizmos)

public class AudioItem : ScriptableObject { }

Assets/Gizmos

"AudioItem Icon.png"

128x128

png named with a normal space between "AudioItem" - name of your class - and "Icon".