public override void OnInspectorGUI() { // Button to pop up window to edit the asset. if (GUILayout.Button("Edit asset")) { AssetInspectorWindow.OnOpenAsset(GetAsset().GetInstanceID(), 0); } EditorGUILayout.Space(); // Importer settings UI. var generateWapperCodeProperty = serializedObject.FindProperty("m_GenerateWrapperCode"); EditorGUILayout.PropertyField(generateWapperCodeProperty, m_GenerateWrapperCodeLabel); if (generateWapperCodeProperty.boolValue) { var wrapperCodePathProperty = serializedObject.FindProperty("m_WrapperCodePath"); var wrapperClassNameProperty = serializedObject.FindProperty("m_WrapperClassName"); var wrapperCodeNamespaceProperty = serializedObject.FindProperty("m_WrapperCodeNamespace"); var generateActionEventsProperty = serializedObject.FindProperty("m_GenerateActionEvents"); var generateInterfacesProperty = serializedObject.FindProperty("m_GenerateInterfaces"); ////TODO: tie a file selector to this EditorGUILayout.PropertyField(wrapperCodePathProperty, m_WrapperCodePathLabel); EditorGUILayout.PropertyField(wrapperClassNameProperty, m_WrapperClassNameLabel); if (!CSharpCodeHelpers.IsEmptyOrProperIdentifier(wrapperClassNameProperty.stringValue)) { EditorGUILayout.HelpBox("Must be a valid C# identifier", MessageType.Error); } EditorGUILayout.PropertyField(wrapperCodeNamespaceProperty, m_WrapperCodeNamespaceLabel); if (!CSharpCodeHelpers.IsEmptyOrProperNamespaceName(wrapperCodeNamespaceProperty.stringValue)) { EditorGUILayout.HelpBox("Must be a valid C# namespace name", MessageType.Error); } EditorGUILayout.PropertyField(generateActionEventsProperty, m_GenerateActionEventsLabel); EditorGUILayout.PropertyField(generateInterfacesProperty); } ApplyRevertGUI(); }
public override void OnInspectorGUI() { // Button to pop up window to edit the asset. if (GUILayout.Button("Edit asset")) { AssetInspectorWindow.OnOpenAsset(GetAsset().GetInstanceID(), 0); } EditorGUILayout.Space(); // Importer settings UI. var generateWapperCodeProperty = serializedObject.FindProperty("m_GenerateWrapperCode"); EditorGUILayout.PropertyField(generateWapperCodeProperty, m_GenerateWrapperCodeLabel); if (generateWapperCodeProperty.boolValue) { var wrapperCodePathProperty = serializedObject.FindProperty("m_WrapperCodePath"); var wrapperClassNameProperty = serializedObject.FindProperty("m_WrapperClassName"); var wrapperCodeNamespaceProperty = serializedObject.FindProperty("m_WrapperCodeNamespace"); var generateActionEventsProperty = serializedObject.FindProperty("m_GenerateActionEvents"); var generateInterfacesProperty = serializedObject.FindProperty("m_GenerateInterfaces"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(wrapperCodePathProperty, m_WrapperCodePathLabel); if (GUILayout.Button("...", EditorStyles.miniButton, GUILayout.MaxWidth(20))) { var assetPath = AssetDatabase.GetAssetPath(GetAsset()); var defaultFileName = Path.ChangeExtension(assetPath, ".cs"); var fileName = EditorUtility.SaveFilePanel("Location for generated C# file", Path.GetDirectoryName(defaultFileName), Path.GetFileName(defaultFileName), "cs"); if (!string.IsNullOrEmpty(fileName)) { if (fileName.StartsWith(Application.dataPath)) { fileName = "Assets/" + fileName.Substring(Application.dataPath.Length + 1); } wrapperCodePathProperty.stringValue = fileName; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.PropertyField(wrapperClassNameProperty, m_WrapperClassNameLabel); if (!CSharpCodeHelpers.IsEmptyOrProperIdentifier(wrapperClassNameProperty.stringValue)) { EditorGUILayout.HelpBox("Must be a valid C# identifier", MessageType.Error); } EditorGUILayout.PropertyField(wrapperCodeNamespaceProperty, m_WrapperCodeNamespaceLabel); if (!CSharpCodeHelpers.IsEmptyOrProperNamespaceName(wrapperCodeNamespaceProperty.stringValue)) { EditorGUILayout.HelpBox("Must be a valid C# namespace name", MessageType.Error); } EditorGUILayout.PropertyField(generateActionEventsProperty, m_GenerateActionEventsLabel); EditorGUILayout.PropertyField(generateInterfacesProperty); } ApplyRevertGUI(); }