7502018d20
There is an asset in the store I grabbed. the coding is WAY above my head, I got about half of it and integrated and adapted what I can to it. im going as far as I can with it and ill come back in a few month when I understand t better.
103 lines
3.4 KiB
C#
103 lines
3.4 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
using ModTool.Shared;
|
|
using System;
|
|
|
|
namespace ModTool.Editor.Exporting
|
|
{
|
|
[CustomEditor(typeof(ExportSettings))]
|
|
public class ExportSettingsEditor : UnityEditor.Editor
|
|
{
|
|
private SerializedProperty _name;
|
|
private SerializedProperty _author;
|
|
private SerializedProperty _description;
|
|
private SerializedProperty _version;
|
|
private SerializedProperty _creationDate;
|
|
private SerializedProperty _platforms;
|
|
private SerializedProperty _content;
|
|
private SerializedProperty _outputDirectory;
|
|
private SerializedProperty _coverImage;
|
|
|
|
private FilteredEnumMaskField platforms;
|
|
private FilteredEnumMaskField content;
|
|
|
|
void OnEnable()
|
|
{
|
|
_name = serializedObject.FindProperty("_name");
|
|
_author = serializedObject.FindProperty("_author");
|
|
_description = serializedObject.FindProperty("_description");
|
|
_version = serializedObject.FindProperty("_version");
|
|
_creationDate = serializedObject.FindProperty("_creationDate");
|
|
_platforms = serializedObject.FindProperty("_platforms");
|
|
_content = serializedObject.FindProperty("_content");
|
|
_outputDirectory = serializedObject.FindProperty("_outputDirectory");
|
|
_coverImage = serializedObject.FindProperty("_coverImage");
|
|
|
|
platforms = new FilteredEnumMaskField(typeof(ModPlatform), (int)ModToolSettings.supportedPlatforms);
|
|
content = new FilteredEnumMaskField(typeof(ModContent), (int)ModToolSettings.supportedContent);
|
|
}
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
serializedObject.Update();
|
|
|
|
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
|
|
GUILayout.Space(5);
|
|
|
|
EditorGUILayout.PropertyField(_name, new GUIContent("Mod Name*:"));
|
|
EditorGUILayout.PropertyField(_author, new GUIContent("Author:"));
|
|
EditorGUILayout.PropertyField(_version, new GUIContent("Version:"));
|
|
EditorGUILayout.PropertyField(_creationDate, new GUIContent("Creation Date:"));
|
|
|
|
EditorGUILayout.PropertyField(_description, new GUIContent("Description:"), GUILayout.Height(60));
|
|
|
|
GUILayout.Space(5);
|
|
|
|
_platforms.intValue = platforms.DoMaskField("Platforms*:", _platforms.intValue);
|
|
_content.intValue = content.DoMaskField("Content*:", _content.intValue);
|
|
_creationDate.stringValue = DateTime.Now.ToString();
|
|
|
|
EditorGUILayout.PropertyField(_coverImage, new GUIContent("Cover Image"));
|
|
|
|
ModToolSettings.logLevel = (LogLevel)EditorGUILayout.EnumPopup("Log Level:", ModToolSettings.logLevel);
|
|
|
|
bool enabled = GUI.enabled;
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
|
GUI.enabled = false;
|
|
|
|
EditorGUILayout.TextField("Output Directory*:", GetShortString(_outputDirectory.stringValue));
|
|
|
|
GUI.enabled = enabled;
|
|
|
|
if (GUILayout.Button("...", GUILayout.Width(30)))
|
|
{
|
|
string selectedDirectory = EditorUtility.SaveFolderPanel("Choose output directory", _outputDirectory.stringValue, "");
|
|
if (!string.IsNullOrEmpty(selectedDirectory))
|
|
_outputDirectory.stringValue = selectedDirectory;
|
|
|
|
Repaint();
|
|
}
|
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
GUILayout.FlexibleSpace();
|
|
|
|
EditorGUILayout.EndVertical();
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
}
|
|
|
|
private string GetShortString(string str)
|
|
{
|
|
int maxWidth = (int)EditorGUIUtility.currentViewWidth - 252;
|
|
int cutoffIndex = Mathf.Max(0, str.Length - 7 - (maxWidth / 7));
|
|
string shortString = str.Substring(cutoffIndex);
|
|
if (cutoffIndex > 0)
|
|
shortString = "..." + shortString;
|
|
return shortString;
|
|
}
|
|
}
|
|
} |