Skip to content

Instantly share code, notes, and snippets.



Last active Dec 23, 2017
What would you like to do?
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public enum StateID
None, Idle, Run, Boost, JumpStart, Jumping, JumpEnd, Down, DownRecover,
Step_Forward, Step_Back, Step_Left, Step_Right,
Run_F, Run_B, Run_L, Run_R
public class LayoutTest : MonoBehaviour
public class Content
public AnimationClip clip;
public Transform trans;
public List<Content> contents = new List<Content>();
public class MyEditor : Editor
public override void OnInspectorGUI()
LayoutTest a = target as LayoutTest;
EditorGUIUtility.labelWidth = 80;
GUIStyle back0 = new GUIStyle();
back0.normal.background = MakeTex(600, 1, new Color(0.4f, 0.4f, 0.4f, 0.1f));
GUIStyle back1 = new GUIStyle();
back1.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.1f));
bool isEven = true;
foreach (StateID stateID in Enum.GetValues(typeof(StateID)))
int i = (int)stateID;
a.contents.Add(new Content());
if (isEven)
isEven = !isEven;
EditorGUILayout.LabelField(stateID.ToString(), EditorStyles.boldLabel, GUILayout.Width(150));
GUI.backgroundColor = (manager.contents[i].clip != null) ? Color.yellow : Color.white;
a.contents[i].clip = EditorGUILayout.ObjectField("AnimClip", a.contents[i].clip, typeof(AnimationClip), false) as AnimationClip;
GUI.backgroundColor = (manager.contents[i].clip != null) ? Color.yellow : Color.white;
a.contents[i].trans = EditorGUILayout.ObjectField("Transform", a.contents[i].trans, typeof(Transform), true) as Transform;
GUI.backgroundColor = Color.white;
private Texture2D MakeTex(int width, int height, Color col)
Color[] pix = new Color[width * height];
for (int i = 0; i < pix.Length; i++)
pix[i] = col;
Texture2D result = new Texture2D(width, height);
return result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment