view Orchestland/Assets/LeapMotion/Editor/LeapImageRetrieverEditor.cs @ 3:0030a1b971fb default tip

merge
author Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
date Fri, 17 Jul 2015 23:23:43 +0900
parents f7675884f2a1
children
line wrap: on
line source

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor (typeof (LeapImageRetriever))]
public class LeapImageRetrieverEditor : Editor {

    public override void OnInspectorGUI() {
        base.OnInspectorGUI();

        SerializedProperty eyeProperty = serializedObject.FindProperty("eye");
        if (eyeProperty.enumValueIndex == -1) {
            LeapImageRetriever retrieverScript = target as LeapImageRetriever;
            bool containsLeft = retrieverScript.gameObject.name.ToLower().Contains("left");
            eyeProperty.enumValueIndex = containsLeft ? (int)LeapImageRetriever.EYE.LEFT : (int)LeapImageRetriever.EYE.RIGHT;
            serializedObject.ApplyModifiedProperties();
        }
    }
}