testss
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class VSProjectSettingsProvider : Editor
|
||||
{
|
||||
[SettingsProvider]
|
||||
public static SettingsProvider CreateProjectSettingProvider()
|
||||
{
|
||||
return new VSProjectSettingsProviderView();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
class VSProjectSettingsProviderView : SettingsProvider
|
||||
{
|
||||
private const string path = "Project/Visual Scripting";
|
||||
private const string title = "Visual Scripting";
|
||||
private const string titleGroup = "Generate Units";
|
||||
|
||||
VSSettingsAssembly vsSettingsAssembly;
|
||||
VSSettingsTypeOption vsSettingsTypeOption;
|
||||
VSSettingsCustomProperty vsSettingsCustomProperty;
|
||||
VSSettingsBackup vsSettingsBackup;
|
||||
VSSettingsScriptReferenceResolver vsSettingsScriptReferenceResolver;
|
||||
|
||||
public VSProjectSettingsProviderView() : base(path, SettingsScope.Project)
|
||||
{
|
||||
label = title;
|
||||
}
|
||||
|
||||
private void CreateOptionsIfNeeded()
|
||||
{
|
||||
if (vsSettingsAssembly == null)
|
||||
{
|
||||
vsSettingsAssembly = new VSSettingsAssembly();
|
||||
}
|
||||
|
||||
if (vsSettingsTypeOption == null)
|
||||
{
|
||||
vsSettingsTypeOption = new VSSettingsTypeOption();
|
||||
}
|
||||
|
||||
if (vsSettingsCustomProperty == null)
|
||||
{
|
||||
vsSettingsCustomProperty = new VSSettingsCustomProperty();
|
||||
}
|
||||
|
||||
if (vsSettingsBackup == null)
|
||||
{
|
||||
vsSettingsBackup = new VSSettingsBackup();
|
||||
}
|
||||
|
||||
if (vsSettingsScriptReferenceResolver == null)
|
||||
{
|
||||
vsSettingsScriptReferenceResolver = new VSSettingsScriptReferenceResolver();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(string searchContext)
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
|
||||
GUILayout.Label(titleGroup, EditorStyles.boldLabel);
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
// happens when opening unity with the settings window already opened. there's a delay until the singleton is assigned
|
||||
if (BoltCore.instance == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Loading Configuration...", MessageType.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
CreateOptionsIfNeeded();
|
||||
|
||||
vsSettingsTypeOption.OnGUI();
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
vsSettingsAssembly.OnGUI();
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
vsSettingsCustomProperty.OnGUI();
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
vsSettingsBackup.OnGUI();
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
vsSettingsScriptReferenceResolver.OnGUI();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class VSSettingsAssembly
|
||||
{
|
||||
private const string completeLabel = "Regenerate Units";
|
||||
private PluginConfigurationItemMetadata assemblyOptionsMetadata;
|
||||
|
||||
private bool showAssembly = false;
|
||||
private const string titleAssembly = "Node Library";
|
||||
private const string descriptionAssembly = "Choose the assemblies in which you want to look for units.\n"
|
||||
+ "By default, all project and Unity assemblies are included.\n"
|
||||
+ "Unless you use a third-party plugin distributed as a DLL, you shouldn't need to change this.";
|
||||
public VSSettingsAssembly()
|
||||
{
|
||||
assemblyOptionsMetadata = BoltCore.Configuration.GetMetadata(nameof(BoltCoreConfiguration.assemblyOptions));
|
||||
}
|
||||
|
||||
static class Styles
|
||||
{
|
||||
public static readonly GUIStyle background;
|
||||
public static readonly GUIStyle defaultsButton;
|
||||
public static readonly float optionsWidth = 250;
|
||||
|
||||
static Styles()
|
||||
{
|
||||
background = new GUIStyle(LudiqStyles.windowBackground);
|
||||
background.padding = new RectOffset(20, 20, 20, 20);
|
||||
|
||||
defaultsButton = new GUIStyle("Button");
|
||||
defaultsButton.padding = new RectOffset(10, 10, 4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
showAssembly = EditorGUILayout.Foldout(showAssembly, new GUIContent(titleAssembly, descriptionAssembly));
|
||||
|
||||
if (showAssembly)
|
||||
{
|
||||
GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));
|
||||
|
||||
float height = LudiqGUI.GetInspectorHeight(null, assemblyOptionsMetadata, Styles.optionsWidth, GUIContent.none);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);
|
||||
|
||||
LudiqGUI.Inspector(assemblyOptionsMetadata, position, GUIContent.none);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
assemblyOptionsMetadata.Save();
|
||||
Codebase.UpdateSettings();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
|
||||
{
|
||||
assemblyOptionsMetadata.Reset(true);
|
||||
assemblyOptionsMetadata.Save();
|
||||
}
|
||||
|
||||
LudiqGUI.EndVertical();
|
||||
}
|
||||
|
||||
if (GUILayout.Button(completeLabel, Styles.defaultsButton))
|
||||
{
|
||||
UnitBase.Rebuild();
|
||||
|
||||
EditorUtility.DisplayDialog("Visual Script", "Regenerate Units completed", "OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
using System.Diagnostics;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class VSSettingsBackup
|
||||
{
|
||||
private const string title = "Backup Graphs";
|
||||
private const string buttonBackupLabel = "Create Backup";
|
||||
private const string buttonRestoreLabel = "Restore Backup";
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
|
||||
GUILayout.Label(title, EditorStyles.boldLabel);
|
||||
|
||||
GUILayout.Space(5f);
|
||||
|
||||
if (GUILayout.Button(buttonBackupLabel, Styles.defaultsButton))
|
||||
{
|
||||
VSBackupUtility.Backup();
|
||||
|
||||
EditorUtility.DisplayDialog("Backup", "Backup completed successfully.", "OK");
|
||||
}
|
||||
|
||||
if (GUILayout.Button(buttonRestoreLabel, Styles.defaultsButton))
|
||||
{
|
||||
PathUtility.CreateDirectoryIfNeeded(Paths.backups);
|
||||
Process.Start(Paths.backups);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Styles
|
||||
{
|
||||
static Styles()
|
||||
{
|
||||
defaultsButton = new GUIStyle("Button");
|
||||
defaultsButton.padding = new RectOffset(10, 10, 4, 4);
|
||||
}
|
||||
|
||||
public static readonly GUIStyle defaultsButton;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class VSSettingsCustomProperty
|
||||
{
|
||||
private const string title = "Custom Inspector Properties";
|
||||
private const string buttonLabel = "Generate";
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
|
||||
GUILayout.Label(title, EditorStyles.boldLabel);
|
||||
|
||||
GUILayout.Space(5f);
|
||||
|
||||
string label = "Inspectors in Bolt plugins can handle many custom types besides Unity primites and objects. ";
|
||||
label += "However, to be compatible with your custom editor drawers, some additional property provider scripts must be generated. ";
|
||||
|
||||
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
||||
GUILayout.Label(EditorGUIUtility.IconContent("console.infoicon"), GUILayout.ExpandWidth(true));
|
||||
GUILayout.Box(label, EditorStyles.wordWrappedLabel);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
if (GUILayout.Button(buttonLabel, Styles.defaultsButton))
|
||||
{
|
||||
SerializedPropertyProviderProvider.instance.GenerateProviderScripts();
|
||||
EditorUtility.DisplayDialog("Custom Inspector Generation", "Custom inspector generation has completed successfully.", "OK");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Styles
|
||||
{
|
||||
static Styles()
|
||||
{
|
||||
defaultsButton = new GUIStyle("Button");
|
||||
defaultsButton.padding = new RectOffset(10, 10, 4, 4);
|
||||
|
||||
regenerateLabel = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
|
||||
regenerateLabel.wordWrap = true;
|
||||
}
|
||||
|
||||
public static readonly GUIStyle defaultsButton;
|
||||
public static readonly GUIStyle regenerateLabel;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "VSSettingsProvider",
|
||||
"references": [
|
||||
"Unity.VisualScripting.Core",
|
||||
"Unity.VisualScripting.Core.Editor",
|
||||
"Unity.VisualScripting.Flow",
|
||||
"Unity.VisualScripting.Flow.Editor",
|
||||
"Unity.VisualScripting.State"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class VSSettingsScriptReferenceResolver
|
||||
{
|
||||
private const string title = "Script Reference Resolver";
|
||||
private const string buttonLabel = "Fix Missing Scripts";
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
GUILayout.Space(5f);
|
||||
|
||||
GUILayout.Label(title, EditorStyles.boldLabel);
|
||||
|
||||
GUILayout.Space(5f);
|
||||
|
||||
if (GUILayout.Button(buttonLabel, Styles.defaultsButton))
|
||||
{
|
||||
ScriptReferenceResolver.Run(ScriptReferenceResolver.Mode.Dialog);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Styles
|
||||
{
|
||||
static Styles()
|
||||
{
|
||||
defaultsButton = new GUIStyle("Button");
|
||||
defaultsButton.padding = new RectOffset(10, 10, 4, 4);
|
||||
|
||||
regenerateLabel = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
|
||||
regenerateLabel.wordWrap = true;
|
||||
}
|
||||
|
||||
public static readonly GUIStyle defaultsButton;
|
||||
public static readonly GUIStyle regenerateLabel;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class VSSettingsTypeOption
|
||||
{
|
||||
private readonly PluginConfigurationItemMetadata typeOptionsMetadata;
|
||||
|
||||
bool showTypeOption = false;
|
||||
private const string titleTypeOption = "Type Options";
|
||||
private const string descriptionTypeOption = "Choose the types you want to use for variables and units.\n"
|
||||
+ "MonoBehaviour types are always included.";
|
||||
static class Styles
|
||||
{
|
||||
public static readonly GUIStyle background;
|
||||
public static readonly GUIStyle defaultsButton;
|
||||
public static readonly float optionsWidth = 250;
|
||||
|
||||
static Styles()
|
||||
{
|
||||
background = new GUIStyle(LudiqStyles.windowBackground);
|
||||
background.padding = new RectOffset(20, 20, 20, 20);
|
||||
|
||||
defaultsButton = new GUIStyle("Button");
|
||||
defaultsButton.padding = new RectOffset(10, 10, 4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public VSSettingsTypeOption()
|
||||
{
|
||||
typeOptionsMetadata = BoltCore.Configuration.GetMetadata(nameof(BoltCoreConfiguration.typeOptions));
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
showTypeOption = EditorGUILayout.Foldout(showTypeOption, new GUIContent(titleTypeOption, descriptionTypeOption));
|
||||
|
||||
if (showTypeOption)
|
||||
{
|
||||
GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));
|
||||
|
||||
float height =
|
||||
LudiqGUI.GetInspectorHeight(null, typeOptionsMetadata, Styles.optionsWidth, GUIContent.none);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);
|
||||
|
||||
LudiqGUI.Inspector(typeOptionsMetadata, position, GUIContent.none);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
typeOptionsMetadata.Save();
|
||||
Codebase.UpdateSettings();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
|
||||
{
|
||||
typeOptionsMetadata.Reset(true);
|
||||
typeOptionsMetadata.Save();
|
||||
}
|
||||
|
||||
LudiqGUI.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user