public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (m_utility == null) { m_utility = new HandPoseDataEditorUtility(property, "handPose."); } if (m_prop_presets == null) { m_prop_presets = property.FindPropertyRelative("presets"); } var presets = m_prop_presets.objectReferenceValue as HandPosePresetsAsset; if (presets == null) { presets = HandPosePresetsAsset.GetDefaultGetPresetsAsset(); m_prop_presets.objectReferenceValue = presets; } var singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); EditorGUI.PropertyField(singleFieldRect, m_prop_presets); position.y += EditorGUIUtility.singleLineHeight; position.height -= EditorGUIUtility.singleLineHeight; m_utility.DrawFingerControls(position, presets); }
private static bool Load() { var loaded = false; try { var assetPath = BasePath + "/" + kDEFAULT_PRESET_ASSET_FILENAME; if (File.Exists(assetPath)) { s_presetsAsset = AssetDatabase.LoadAssetAtPath <HandPosePresetsAsset>(assetPath); loaded = true; } } catch (Exception e) { Debug.LogException(e); } return(loaded); }
public static HandPosePresetsAsset GetDefaultGetPresetsAsset() { if (s_presetsAsset == null) { if (!Load()) { // Create vanilla db s_presetsAsset = CreateInstance <HandPosePresetsAsset>(); s_presetsAsset.presets = new List <HandPosePreset>(); var basePath = BasePath; if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } AssetDatabase.CreateAsset(s_presetsAsset, basePath + "/" + kDEFAULT_PRESET_ASSET_FILENAME); } } return(s_presetsAsset); }
public static HandPosePresetsAsset GetPresetsAsset() { if (s_presetsAsset == null) { if (!Load()) { // Create vanilla db s_presetsAsset = CreateInstance <HandPosePresetsAsset>(); s_presetsAsset.presets = new List <HandPosePreset>(); var basePath = BasePath; if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } AssetDatabase.CreateAsset(s_presetsAsset, basePath + "/" + s_presetAssetFilename); } } return(s_presetsAsset); }