Storyline+Dialog初步
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace SubAssetsToolbox.Editor
|
||||
{
|
||||
public enum ReferencePatchingMode
|
||||
{
|
||||
Disabled = 0,
|
||||
AskEachTime = 1,
|
||||
AutoApply = 2
|
||||
}
|
||||
|
||||
public class SubAssetsToolboxSettings
|
||||
{
|
||||
public static PackageSetting<bool> WelcomeWindowSeen = new("general.welcomeWindowSeen", false);
|
||||
|
||||
public static readonly string[] DefaultExtensionsToScan =
|
||||
{
|
||||
"unity", "prefab", "asset", "mat", "controller", "overrideController",
|
||||
"playable", "signal", "mixer", "preset", "lighting", "giparams",
|
||||
"spriteatlas", "spriteatlasv2", "terrainlayer", "brush", "anim",
|
||||
"guiskin", "fontsettings", "flare", "renderTexture", "cubemap"
|
||||
};
|
||||
|
||||
public static PackageSetting<ReferencePatchingMode> PatchReferences =
|
||||
new("referencePatching.mode", ReferencePatchingMode.AskEachTime);
|
||||
|
||||
public static PackageSetting<string[]> PatchExtensions =
|
||||
new("referencePatching.extensions", DefaultExtensionsToScan);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e40b070acac1a4ec488641be6b410275
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 284154
|
||||
packageName: SubAssets Toolbox
|
||||
packageVersion: 1.1.0
|
||||
assetPath: Packages/io.continis.subassets/Editor/Settings/SubAssetsToolboxSettings.cs
|
||||
uploadId: 869944
|
||||
@@ -0,0 +1,33 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.SettingsManagement;
|
||||
|
||||
namespace SubAssetsToolbox.Editor
|
||||
{
|
||||
static class SubAssetsToolboxSettingsManager
|
||||
{
|
||||
private static Settings instance;
|
||||
|
||||
internal static Settings settings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new Settings(Constants.PackageName, "Settings");
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PackageSetting<T> : UserSetting<T>
|
||||
{
|
||||
public PackageSetting(string key, T value)
|
||||
: base(SubAssetsToolboxSettingsManager.settings, key, value, SettingsScope.Project) { }
|
||||
}
|
||||
|
||||
public class UserPref<T> : UserSetting<T>
|
||||
{
|
||||
public UserPref(string key, T value)
|
||||
: base(SubAssetsToolboxSettingsManager.settings, key, value, SettingsScope.User) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 866ebc740692e48a6818f6a8a101bb8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 284154
|
||||
packageName: SubAssets Toolbox
|
||||
packageVersion: 1.1.0
|
||||
assetPath: Packages/io.continis.subassets/Editor/Settings/SubAssetsToolboxSettingsManager.cs
|
||||
uploadId: 869944
|
||||
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace SubAssetsToolbox.Editor
|
||||
{
|
||||
internal static class SubAssetsToolboxSettingsProvider
|
||||
{
|
||||
private const string SettingsPath = "Project/SubAssets Toolbox";
|
||||
private const string UxmlPath = "Packages/io.continis.subassets/UI/UIToolkit/ProjectSettings.uxml";
|
||||
|
||||
private static List<string> _extensions;
|
||||
private static ListView _listView;
|
||||
private static EnumField _redirectionModeField;
|
||||
private static Button _resetFileTypesBtn;
|
||||
|
||||
[SettingsProvider]
|
||||
private static SettingsProvider CreateSettingsProvider()
|
||||
{
|
||||
return new SettingsProvider(SettingsPath, SettingsScope.Project)
|
||||
{
|
||||
activateHandler = (_, rootElement) => CreateUI(rootElement),
|
||||
keywords = new[] { "subassets", "sub-assets", "redirect", "extensions" }
|
||||
};
|
||||
}
|
||||
|
||||
private static void SyncToSetting()
|
||||
{
|
||||
SubAssetsToolboxSettings.PatchExtensions.SetValue(_extensions.ToArray(), true);
|
||||
}
|
||||
|
||||
private static void CreateUI(VisualElement root)
|
||||
{
|
||||
ReferencePatchingMode currentMode = SubAssetsToolboxSettings.PatchReferences.value;
|
||||
bool redirectionIsEnabled = currentMode != ReferencePatchingMode.Disabled;
|
||||
_extensions = new List<string>(SubAssetsToolboxSettings.PatchExtensions.value);
|
||||
|
||||
VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UxmlPath);
|
||||
VisualElement template = visualTree.Instantiate();
|
||||
template.style.flexGrow = 1f;
|
||||
|
||||
_redirectionModeField = template.Q<EnumField>("RedirectionModeField");
|
||||
_redirectionModeField.Init(ReferencePatchingMode.Disabled);
|
||||
_redirectionModeField.SetValueWithoutNotify(currentMode);
|
||||
_redirectionModeField.RegisterValueChangedCallback(OnRedirectionModeChanged);
|
||||
|
||||
_listView = template.Q<ListView>("ExtensionsList");
|
||||
_listView.itemsSource = _extensions;
|
||||
_listView.SetEnabled(redirectionIsEnabled);
|
||||
_listView.makeItem = MakeItem;
|
||||
_listView.bindItem = BindItem;
|
||||
_listView.unbindItem = UnbindItem;
|
||||
|
||||
_listView.itemsAdded += indices =>
|
||||
{
|
||||
foreach (int i in indices)
|
||||
_extensions[i] = "ext";
|
||||
_listView.RefreshItems();
|
||||
SyncToSetting();
|
||||
};
|
||||
|
||||
_listView.itemsRemoved += _ => SyncToSetting();
|
||||
_listView.itemIndexChanged += (_, _) => SyncToSetting();
|
||||
|
||||
_resetFileTypesBtn = template.Q<Button>("ResetBtn");
|
||||
_resetFileTypesBtn.SetEnabled(redirectionIsEnabled);
|
||||
_resetFileTypesBtn.clicked += ResetExtensionsToDefaults;
|
||||
|
||||
root.Add(template);
|
||||
}
|
||||
|
||||
private static void OnRedirectionModeChanged(ChangeEvent<Enum> evt)
|
||||
{
|
||||
ReferencePatchingMode mode = (ReferencePatchingMode)evt.newValue;
|
||||
SubAssetsToolboxSettings.PatchReferences.SetValue(mode, true);
|
||||
bool enabled = mode != ReferencePatchingMode.Disabled;
|
||||
_listView.SetEnabled(enabled);
|
||||
_resetFileTypesBtn.SetEnabled(enabled);
|
||||
}
|
||||
|
||||
private static void ResetExtensionsToDefaults()
|
||||
{
|
||||
_extensions.Clear();
|
||||
_extensions.AddRange(SubAssetsToolboxSettings.DefaultExtensionsToScan);
|
||||
_listView.RefreshItems();
|
||||
SyncToSetting();
|
||||
}
|
||||
|
||||
private static VisualElement MakeItem()
|
||||
{
|
||||
return new TextField();
|
||||
}
|
||||
|
||||
private static void BindItem(VisualElement element, int index)
|
||||
{
|
||||
TextField field = (TextField)element;
|
||||
field.SetValueWithoutNotify(_extensions[index]);
|
||||
field.userData = index;
|
||||
field.RegisterValueChangedCallback(OnExtensionChanged);
|
||||
}
|
||||
|
||||
private static void UnbindItem(VisualElement element, int index)
|
||||
{
|
||||
TextField field = (TextField)element;
|
||||
field.UnregisterValueChangedCallback(OnExtensionChanged);
|
||||
}
|
||||
|
||||
private static void OnExtensionChanged(ChangeEvent<string> evt)
|
||||
{
|
||||
TextField field = (TextField)evt.target;
|
||||
int index = (int)field.userData;
|
||||
_extensions[index] = evt.newValue;
|
||||
SyncToSetting();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9fe270b76b734b60a6b7c24fcf38c43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 284154
|
||||
packageName: SubAssets Toolbox
|
||||
packageVersion: 1.1.0
|
||||
assetPath: Packages/io.continis.subassets/Editor/Settings/SubAssetsToolboxSettingsProvider.cs
|
||||
uploadId: 869944
|
||||
Reference in New Issue
Block a user