added yarn spinner package
This commit is contained in:
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Text Animator for Yarn Spinner is licensed to you under the terms found in the file LICENSE.md.
|
||||
*/
|
||||
|
||||
#if YS_USE_TEXT_ANIMATOR_2 || YS_USE_TEXT_ANIMATOR_3
|
||||
#define USE_TEXT_ANIMATOR
|
||||
#endif
|
||||
|
||||
namespace Yarn.Unity.Addons.TextAnimatorIntegration.Editor
|
||||
{
|
||||
#nullable enable
|
||||
#if USE_TEXT_ANIMATOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
// Literally copy-pasted from YS, just with a different menuitem and guid
|
||||
public static class CreateTextAnimatorDialogueRunnerMenuItem
|
||||
{
|
||||
// gonna have to change this so that it uses a different guid for each one
|
||||
// which sucks but oh well
|
||||
#if YS_USE_TEXT_ANIMATOR_3
|
||||
const string DialogueRunnerPrefabGUID = "cd09801223b5f4504a921d33ef1ff98c";
|
||||
#elif YS_USE_TEXT_ANIMATOR_2
|
||||
const string DialogueRunnerPrefabGUID = "eeb327a65c4bc4376ae432ce641f04af";
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates the Dialogue System prefab in the currently active scene,
|
||||
/// and returns the created <see cref="DialogueRunner"/>.
|
||||
/// </summary>
|
||||
/// <returns>A newly created <see cref="DialogueRunner"/>.</returns>
|
||||
/// <exception cref="System.InvalidOperationException">Thrown when the
|
||||
/// Dialogue System prefab cannot be found in the Yarn Spinner
|
||||
/// package.</exception>
|
||||
[MenuItem("GameObject/Yarn Spinner/Dialogue System with Text Animator")]
|
||||
public static DialogueRunner CreateDialogueRunner()
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(DialogueRunnerPrefabGUID);
|
||||
var prefabAsset = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||
|
||||
if (prefabAsset == null)
|
||||
{
|
||||
throw new System.InvalidOperationException(
|
||||
$"Can't create a new Dialogue System: Can't find the prefab to create a Dialogue System from."
|
||||
);
|
||||
}
|
||||
|
||||
var instantiatedPrefab = (GameObject)PrefabUtility.InstantiatePrefab(prefabAsset);
|
||||
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
var eventSystems = Object.FindObjectsByType<EventSystem>(FindObjectsSortMode.None);
|
||||
#else
|
||||
var eventSystems = Object.FindObjectsOfType<EventSystem>();
|
||||
#endif
|
||||
|
||||
if (eventSystems.Length > 1)
|
||||
{
|
||||
// At least one other event system is present in the scene. Turn off
|
||||
// the one that came with the prefab - it's not needed.
|
||||
var instantiatedEventSystem = instantiatedPrefab.GetComponentInChildren<EventSystem>();
|
||||
|
||||
instantiatedEventSystem.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
return instantiatedPrefab.GetComponent<DialogueRunner>();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff74191f08b6d4d5488de8f2e633dfd4
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/CreateTextAnimatorDialogueRunnerMenuItem.cs
|
||||
uploadId: 968678
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/TextAnimatorConfigurationWindow.uss?fileID=7433441132597879392&guid=e52662955dcee47bbbe24c3602e61bf7&type=3#TextAnimatorConfigurationWindow" />
|
||||
<engine:Label text="Text Animator for Unity is installed and Yarn Spinner is correctly configured to use it." style="white-space: normal; -unity-text-align: upper-left; margin-bottom: 4px; flex-wrap: wrap; margin-left: 4px;" />
|
||||
<engine:Label text="The default Yarn Spinner action has not been registered with Text Animator yet. Depending on your setup this may not be an issue, if you want to register it you can here. Otherwise each typewriter will need to ensure their own action is registered." name="definedLabel" style="white-space: normal; -unity-text-align: upper-left; margin-left: 4px;" />
|
||||
<engine:Button text="Register action" name="definedButton" style="margin-left: 8px; margin-right: 8px;" />
|
||||
</engine:UXML>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02d739c3d6bb545fdb6d4bf14bf07822
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/InstalledAndDefinedElement.uxml
|
||||
uploadId: 968678
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/TextAnimatorConfigurationWindow.uss?fileID=7433441132597879392&guid=e52662955dcee47bbbe24c3602e61bf7&type=3#TextAnimatorConfigurationWindow" />
|
||||
<engine:Label text="Text Animator for Unity is installed but the scripting defines we use are not configured." style="overflow: visible; flex-wrap: nowrap; white-space: normal; padding-bottom: 8px; margin-bottom: 4px;" />
|
||||
<engine:Label text="This will add the necessary scripting defines to the following build targets:" style="overflow: visible; flex-wrap: nowrap; white-space: normal;" />
|
||||
<engine:VisualElement name="scriptingToggleContainer" style="flex-grow: 1;" />
|
||||
<engine:Button text="Add Scripting Defines" name="scriptingButton" style="margin-left: 8px; margin-right: 8px;" />
|
||||
</engine:UXML>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2fe556531a6644c0b405d6482d9de4f
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/InstalledAndNotDefinedElement.uxml
|
||||
uploadId: 968678
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/TextAnimatorConfigurationWindow.uss?fileID=7433441132597879392&guid=e52662955dcee47bbbe24c3602e61bf7&type=3#TextAnimatorConfigurationWindow" />
|
||||
<engine:Label text="Text Animator for Unity is not installed. You will need to install it before you can use it with Yarn Spinner." style="white-space: normal; margin-left: 4px; flex-wrap: wrap;" />
|
||||
<engine:Button text="Get Text Animator for Unity" name="notInstalledButton" style="margin-left: 8px; margin-right: 8px; margin-bottom: 4px;" />
|
||||
</engine:UXML>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c39c92b7ce46b46329bda933bb30f5fc
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/NotInstalledElement.uxml
|
||||
uploadId: 968678
|
||||
+551
@@ -0,0 +1,551 @@
|
||||
/*
|
||||
Text Animator for Yarn Spinner is licensed to you under the terms found in the file LICENSE.md.
|
||||
*/
|
||||
|
||||
#if YS_USE_TEXT_ANIMATOR_2 || YS_USE_TEXT_ANIMATOR_3
|
||||
#define USE_TEXT_ANIMATOR
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Yarn.Unity.Addons.TextAnimatorIntegration.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor.Build;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
|
||||
#if YS_USE_TEXT_ANIMATOR_2
|
||||
using Febucci.UI;
|
||||
using ActionScriptableBase = Febucci.UI.Actions.ActionScriptableBase;
|
||||
#elif YS_USE_TEXT_ANIMATOR_3
|
||||
using Febucci.TextAnimatorForUnity;
|
||||
using ActionScriptableBase = Febucci.TextAnimatorForUnity.Actions.Core.ActionScriptableBase;
|
||||
#else
|
||||
using ActionScriptableBase = UnityEngine.ScriptableObject;
|
||||
#endif
|
||||
|
||||
public class TextAnimatorConfigurationWindow : EditorWindow
|
||||
{
|
||||
private const string YSTA2Define = "YS_USE_TEXT_ANIMATOR_2";
|
||||
private const string YSTA3Define = "YS_USE_TEXT_ANIMATOR_3";
|
||||
|
||||
private const string TextAnimatorV2SettingsType = "Febucci.UI.TextAnimatorSettings";
|
||||
private const string TextAnimatorV3SettingsType = "Febucci.TextAnimatorForUnity.TextAnimatorSettings";
|
||||
|
||||
private const string TextAnimatorSettingsName = "TextAnimatorSettings";
|
||||
private const string TextAnimatorPageURL = "https://www.febucci.com/tools/text-animator-unity";
|
||||
private const string installedAndNotDefinedUXMLGuid = "b2fe556531a6644c0b405d6482d9de4f";
|
||||
private const string notInstalledUXMLGuid = "c39c92b7ce46b46329bda933bb30f5fc";
|
||||
private const string InstalledAndDefinedUXMLGuid = "02d739c3d6bb545fdb6d4bf14bf07822";
|
||||
|
||||
private const string TextAnimatorRunnerPrefabGuidV2 = "eeb327a65c4bc4376ae432ce641f04af";
|
||||
private const string TextAnimatorRunnerPrefabGuidV3 = "cd09801223b5f4504a921d33ef1ff98c";
|
||||
|
||||
private const string TextAnimatorRunnerPackageGuidV2 = "5a3687d8c4744405692bd44867d6ac58";
|
||||
private const string TextAnimatorRunnerPackageGuidV3 = "014e0ab0fc9ca4cd69ce3203bfe646f9";
|
||||
|
||||
// this is a terrible hack but seems to work
|
||||
// it will get all the possible build targets for whatever version of unity the package is installed in
|
||||
// this works because unity has kindly defined a whole bunch of public static build targets already
|
||||
// would be nicer to be able to go like `NamedBuildTarget.All` and have it return a list of them, but oh well
|
||||
private static List<NamedBuildTarget> AllBuildTargets
|
||||
{
|
||||
get
|
||||
{
|
||||
var targets = new List<NamedBuildTarget>();
|
||||
|
||||
// we have this because there are a few targets (like CloudRendering) that are redirected to a different target
|
||||
// and these change on a unity version basis so we can't just manually ignore them like we do with Unknown
|
||||
// so instead if we have run into a build target with a resolved name that we've already seen we ignore it
|
||||
var names = new HashSet<string>();
|
||||
|
||||
var fields = typeof(NamedBuildTarget).GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
foreach (var field in fields)
|
||||
{
|
||||
// so turns out weird things can happen when trying to set or get defines on unknown
|
||||
// plus it doesn't really mean anything so why bother, let's just skip it
|
||||
if (field.Name == "Unknown")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// if it isn't a NamedBuildTarget we ignore it
|
||||
if (field.FieldType == typeof(NamedBuildTarget))
|
||||
{
|
||||
var t = (NamedBuildTarget)field.GetValue(null);
|
||||
|
||||
// Stadia is deprecated and will throw an error if we
|
||||
// attempt to use it; ignore it
|
||||
if (t.TargetName == "Stadia")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (names.Add(t.TargetName))
|
||||
{
|
||||
targets.Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return targets;
|
||||
}
|
||||
}
|
||||
|
||||
// Because we don't know if TextAnimator is installed we can't really safely add the scripting define
|
||||
// So this property does a check looking for the TextAnimator global settings in the resources folder
|
||||
// if we find something with it's name we then check if the name of the type is what we'd expect
|
||||
// this isn't perfect but seems to work pretty well and is mostly robust to change
|
||||
private bool IsTextAnimatorInstalled
|
||||
{
|
||||
get
|
||||
{
|
||||
var resources = Resources.LoadAll(TextAnimatorSettingsName);
|
||||
foreach (var resource in resources)
|
||||
{
|
||||
if (resource.GetType().ToString().EndsWith(TextAnimatorV2SettingsType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (resource.GetType().ToString().EndsWith(TextAnimatorV3SettingsType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsTextAnimatorV2Installed
|
||||
{
|
||||
get
|
||||
{
|
||||
var resources = Resources.LoadAll(TextAnimatorSettingsName);
|
||||
foreach (var resource in resources)
|
||||
{
|
||||
if (resource.GetType().ToString().EndsWith(TextAnimatorV2SettingsType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsTextAnimatorV3Installed
|
||||
{
|
||||
get
|
||||
{
|
||||
var resources = Resources.LoadAll(TextAnimatorSettingsName);
|
||||
foreach (var resource in resources)
|
||||
{
|
||||
if (resource.GetType().ToString().EndsWith(TextAnimatorV3SettingsType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private string? ScriptingDefine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsTextAnimatorV2Installed)
|
||||
{
|
||||
return YSTA2Define;
|
||||
}
|
||||
else if (IsTextAnimatorV3Installed)
|
||||
{
|
||||
return YSTA3Define;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddDefines(Dictionary<string, bool> filters)
|
||||
{
|
||||
var definitionSymbol = ScriptingDefine;
|
||||
if (string.IsNullOrEmpty(definitionSymbol))
|
||||
{
|
||||
Debug.LogWarning("Was unable to determine the valid scripting define for this version of Text Animator. Cannot add the necessary defines.");
|
||||
return;
|
||||
}
|
||||
foreach (var target in AllBuildTargets)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (filters.TryGetValue(target.TargetName, out var value))
|
||||
{
|
||||
if (value == false)
|
||||
{
|
||||
Debug.Log($"skipping {target.TargetName}");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerSettings.GetScriptingDefineSymbols(target, out var defines);
|
||||
if (defines.Contains(definitionSymbol))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
var allSymbols = defines.ToList();
|
||||
allSymbols.Add(definitionSymbol);
|
||||
PlayerSettings.SetScriptingDefineSymbols(target, allSymbols.ToArray());
|
||||
}
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
Debug.LogWarning($"{target.TargetName} is not supported");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private enum InstallationState
|
||||
{
|
||||
InstalledAndDefined, InstalledAndNotDefined, NotInstalledAndNotDefined, NotInstalledAndDefined,
|
||||
}
|
||||
|
||||
private InstallationState installationState
|
||||
{
|
||||
get
|
||||
{
|
||||
#if USE_TEXT_ANIMATOR
|
||||
if (IsTextAnimatorInstalled)
|
||||
{
|
||||
return InstallationState.InstalledAndDefined;
|
||||
}
|
||||
return InstallationState.NotInstalledAndDefined;
|
||||
#else
|
||||
if (IsTextAnimatorInstalled)
|
||||
{
|
||||
return InstallationState.InstalledAndNotDefined;
|
||||
}
|
||||
return InstallationState.NotInstalledAndNotDefined;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private VisualTreeAsset? m_VisualTreeAsset = default;
|
||||
|
||||
[MenuItem("Window/Yarn Spinner/Text Animator Integration Configuration")]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
TextAnimatorConfigurationWindow window = GetWindow<TextAnimatorConfigurationWindow>(true, "Yarn Spinner Text Animator Configuration", true);
|
||||
|
||||
var height = 438;
|
||||
|
||||
switch (window.installationState)
|
||||
{
|
||||
case InstallationState.NotInstalledAndDefined:
|
||||
goto case InstallationState.NotInstalledAndNotDefined;
|
||||
case InstallationState.NotInstalledAndNotDefined:
|
||||
height += 54;
|
||||
break;
|
||||
case InstallationState.InstalledAndDefined:
|
||||
if (TextAnimationActionState.DefaultActionIsRegistered() == TextAnimationActionState.RegistrationResult.NotRegistered)
|
||||
{
|
||||
height += 99;
|
||||
}
|
||||
else
|
||||
{
|
||||
height += 19;
|
||||
}
|
||||
break;
|
||||
case InstallationState.InstalledAndNotDefined:
|
||||
height += 63 + AllBuildTargets.Count * 19;
|
||||
break;
|
||||
}
|
||||
|
||||
window.minSize = new Vector2(512, height);
|
||||
window.maxSize = window.minSize;
|
||||
window.Show();
|
||||
}
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
VisualElement root = rootVisualElement;
|
||||
|
||||
if (m_VisualTreeAsset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var installation = installationState;
|
||||
string activeContainerGUID = installation switch
|
||||
{
|
||||
InstallationState.InstalledAndDefined => InstalledAndDefinedUXMLGuid,
|
||||
InstallationState.InstalledAndNotDefined => installedAndNotDefinedUXMLGuid,
|
||||
_ => notInstalledUXMLGuid,
|
||||
};
|
||||
|
||||
// Instantiate UXML
|
||||
VisualElement labelFromUXML = m_VisualTreeAsset.Instantiate();
|
||||
root.Add(labelFromUXML);
|
||||
|
||||
root.Q<TemplateContainer>().style.flexGrow = 1;
|
||||
|
||||
var tree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(AssetDatabase.GUIDToAssetPath(activeContainerGUID));
|
||||
if (tree == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var container = tree.CloneTree();
|
||||
root.Add(container);
|
||||
|
||||
switch (installation)
|
||||
{
|
||||
case InstallationState.InstalledAndDefined:
|
||||
CreateInstalledAndDefinedGUI(container);
|
||||
break;
|
||||
|
||||
case InstallationState.InstalledAndNotDefined:
|
||||
CreateInstalledAndNotDefinedGUI(container);
|
||||
break;
|
||||
|
||||
case InstallationState.NotInstalledAndDefined:
|
||||
goto case InstallationState.NotInstalledAndNotDefined;
|
||||
case InstallationState.NotInstalledAndNotDefined:
|
||||
CreateNotInstalledGUI(container);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateInstalledAndNotDefinedGUI(VisualElement root)
|
||||
{
|
||||
var container = root.Q<VisualElement>("scriptingToggleContainer");
|
||||
if (container == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var button = root.Q<Button>("scriptingButton");
|
||||
if (button == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<string, bool> targetValues = new();
|
||||
foreach (var target in AllBuildTargets)
|
||||
{
|
||||
targetValues.Add(target.TargetName, true);
|
||||
|
||||
var targetName = target.TargetName;
|
||||
Toggle toogle = new Toggle(targetName);
|
||||
|
||||
toogle.name = targetName;
|
||||
toogle.style.marginLeft = 20;
|
||||
|
||||
toogle.SetValueWithoutNotify(true);
|
||||
container.Add(toogle);
|
||||
|
||||
toogle.RegisterValueChangedCallback((evt) =>
|
||||
{
|
||||
if (evt.currentTarget is not Toggle t)
|
||||
{
|
||||
return;
|
||||
}
|
||||
targetValues[t.name] = evt.newValue;
|
||||
});
|
||||
}
|
||||
|
||||
button.clicked += () =>
|
||||
{
|
||||
ExtractTextAnimatorPackage();
|
||||
AddDefines(targetValues);
|
||||
};
|
||||
}
|
||||
|
||||
private bool GetAssetExists(string guid)
|
||||
{
|
||||
return string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(guid)) == false;
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0051 // Private member is unused
|
||||
private bool ExtractPackageIfAssetNotPresent(string assetGUID, string packageGUID)
|
||||
{
|
||||
AssetDatabase.Refresh();
|
||||
if (GetAssetExists(assetGUID))
|
||||
{
|
||||
// The runner prefab already exists. Nothing left to do.
|
||||
Debug.Log("Not unpacking Text Animator for Yarn Spinner assets, because it's already in the project.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var pathToPackage = AssetDatabase.GUIDToAssetPath(packageGUID);
|
||||
|
||||
if (pathToPackage == string.Empty)
|
||||
{
|
||||
Debug.LogError($"Failed to find the Text Animator for Yarn Spinner package file to extract!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug.Log("Importing package.");
|
||||
AssetDatabase.ImportPackage(pathToPackage, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
#pragma warning disable
|
||||
|
||||
private void ExtractTextAnimatorPackage()
|
||||
{
|
||||
if (IsTextAnimatorV2Installed)
|
||||
{
|
||||
ExtractPackageIfAssetNotPresent(TextAnimatorRunnerPrefabGuidV2, TextAnimatorRunnerPackageGuidV2);
|
||||
}
|
||||
else if (IsTextAnimatorV3Installed)
|
||||
{
|
||||
ExtractPackageIfAssetNotPresent(TextAnimatorRunnerPrefabGuidV3, TextAnimatorRunnerPackageGuidV3);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorUtility.DisplayDialog(
|
||||
"Unknown Version of TextAnimator",
|
||||
"We aren't able to detect which version of Text Animator you have installed. " +
|
||||
"This means we can't complete the installation. Please contact Yarn Spinner support for help.",
|
||||
"Close");
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateInstalledAndDefinedGUI(VisualElement root)
|
||||
{
|
||||
// at this point we are fine to continue but might as well offer to see if the default action can be registered and do it
|
||||
var message = root.Q<Label>("definedLabel");
|
||||
var button = root.Q<Button>("definedButton");
|
||||
if (message == null || button == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextAnimationActionState.DefaultActionIsRegistered() == TextAnimationActionState.RegistrationResult.NotRegistered)
|
||||
{
|
||||
message.style.display = DisplayStyle.Flex;
|
||||
button.style.display = DisplayStyle.Flex;
|
||||
button.clicked += () =>
|
||||
{
|
||||
this.Close();
|
||||
TextAnimationActionState.RegisterDefaultAction();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
message.style.display = DisplayStyle.None;
|
||||
button.style.display = DisplayStyle.None;
|
||||
}
|
||||
}
|
||||
public void CreateNotInstalledGUI(VisualElement root)
|
||||
{
|
||||
// basically get the button
|
||||
// hook up the call
|
||||
var button = root.Q<Button>("notInstalledButton");
|
||||
if (button == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
button.clicked += GetTextAnimator;
|
||||
}
|
||||
|
||||
private void GetTextAnimator()
|
||||
{
|
||||
this.Close();
|
||||
Application.OpenURL(TextAnimatorConfigurationWindow.TextAnimatorPageURL);
|
||||
}
|
||||
}
|
||||
|
||||
class TextAnimationActionState
|
||||
{
|
||||
internal enum RegistrationResult
|
||||
{
|
||||
NotRegistered, Registered, ExistingRegistration, UnableToResolve,
|
||||
}
|
||||
|
||||
#if YS_USE_TEXT_ANIMATOR_2
|
||||
const string defaultActionGUID = "797c9181a760b4946ab39cc7d835909f";
|
||||
|
||||
internal static RegistrationResult IsActionRegistered(ActionScriptableBase action)
|
||||
{
|
||||
foreach (var registeredAction in TextAnimatorSettings.Instance.actions.defaultDatabase.Data)
|
||||
{
|
||||
if (registeredAction == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (action.TagID == registeredAction.TagID)
|
||||
{
|
||||
if (action.GetType() == registeredAction.GetType())
|
||||
{
|
||||
return RegistrationResult.Registered;
|
||||
}
|
||||
return RegistrationResult.ExistingRegistration;
|
||||
}
|
||||
}
|
||||
return RegistrationResult.NotRegistered;
|
||||
}
|
||||
internal static RegistrationResult DefaultActionIsRegistered()
|
||||
{
|
||||
ActionMarkupAction? value;
|
||||
|
||||
var path = AssetDatabase.GUIDToAssetPath(defaultActionGUID);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return RegistrationResult.UnableToResolve;
|
||||
}
|
||||
|
||||
value = AssetDatabase.LoadAssetAtPath<ActionMarkupAction>(path);
|
||||
if (value == null)
|
||||
{
|
||||
return RegistrationResult.UnableToResolve;
|
||||
}
|
||||
return IsActionRegistered(value);
|
||||
}
|
||||
internal static void RegisterDefaultAction()
|
||||
{
|
||||
ActionMarkupAction? value;
|
||||
|
||||
var path = AssetDatabase.GUIDToAssetPath(defaultActionGUID);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
value = AssetDatabase.LoadAssetAtPath<ActionMarkupAction>(path);
|
||||
if (value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TextAnimatorSettings.Instance.actions.defaultDatabase.Add(value);
|
||||
}
|
||||
internal static void RegisterAction(ActionScriptableBase action)
|
||||
{
|
||||
TextAnimatorSettings.Instance.actions.defaultDatabase.Add(action);
|
||||
}
|
||||
#elif YS_USE_TEXT_ANIMATOR_3
|
||||
// in TA3 we have a custom typewriter so don't need to worry about the registration
|
||||
// so we can just say it's registered and otherwise move on with our life
|
||||
internal static RegistrationResult DefaultActionIsRegistered()
|
||||
{
|
||||
return RegistrationResult.Registered;
|
||||
}
|
||||
internal static void RegisterDefaultAction()
|
||||
{
|
||||
return;
|
||||
}
|
||||
#else
|
||||
internal static RegistrationResult DefaultActionIsRegistered() { return RegistrationResult.UnableToResolve; }
|
||||
internal static void RegisterDefaultAction() { return; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68ffb26081e84448faf47d2dec707c3b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- m_VisualTreeAsset: {fileID: 9197481963319205126, guid: b04973c1fd259487ebb3a4e5292b0c47,
|
||||
type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/TextAnimatorConfigurationWindow.cs
|
||||
uploadId: 968678
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
.custom-label {
|
||||
font-size: 20px;
|
||||
-unity-font-style: bold;
|
||||
color: rgb(68, 138, 255);
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e52662955dcee47bbbe24c3602e61bf7
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/TextAnimatorConfigurationWindow.uss
|
||||
uploadId: 968678
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||
<Style src="project://database/Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/TextAnimatorConfigurationWindow.uss?fileID=7433441132597879392&guid=e52662955dcee47bbbe24c3602e61bf7&type=3#TextAnimatorConfigurationWindow" />
|
||||
<engine:VisualElement style="flex-grow: 1; background-image: url("project://database/Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/banner.jpg?fileID=21300000&guid=a4bc00c6001e94d6d85534ee24530d57&type=3#banner"); min-width: 315px; min-height: 250px; background-position-x: center 0; background-position-y: center 0; -unity-background-scale-mode: scale-to-fit; flex-direction: column;" />
|
||||
<engine:Label text="Text Animator for Unity is a 3rd Party asset for creating gorgeous text effects." style="white-space: normal; margin-top: 2px; flex-wrap: wrap; -unity-text-align: upper-center; margin-bottom: 4px;" />
|
||||
</engine:UXML>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b04973c1fd259487ebb3a4e5292b0c47
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/TextAnimatorConfigurationWindow.uxml
|
||||
uploadId: 968678
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Yarn.Unity.Addons.TextAnimatorIntegration;
|
||||
using Yarn.Unity.Editor;
|
||||
using Yarn.Unity.Addons.TextAnimatorIntegration.Editor;
|
||||
|
||||
namespace Yarn.Unity.Addons.TextAnimatorIntegration
|
||||
{
|
||||
|
||||
#if YS_USE_TEXT_ANIMATOR_2
|
||||
[CustomEditor(typeof(TextAnimatorYarnTypewriter))]
|
||||
public class TextAnimatorTypewriterEditor : YarnEditor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
var value = target as TextAnimatorYarnTypewriter;
|
||||
if (value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.insertionAction == null)
|
||||
{
|
||||
if (value.tagMode != TagMode.TextAnimatorOnlyTags)
|
||||
{
|
||||
EditorGUILayout.HelpBox($"The tag mode is set to be {value.tagMode}, but {nameof(value.insertionAction)} is null. You must have an action configured to use this tag mode.", MessageType.Warning);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var tagID = value.insertionAction.TagID ?? "NULL";
|
||||
var registrationStatus = TextAnimationActionState.IsActionRegistered(value.insertionAction);
|
||||
|
||||
switch (registrationStatus)
|
||||
{
|
||||
case TextAnimationActionState.RegistrationResult.ExistingRegistration:
|
||||
if (value.tagMode != TagMode.TextAnimatorOnlyTags)
|
||||
{
|
||||
EditorGUILayout.HelpBox($"There already exists a Text Animator action registered with tag id: \"{tagID}\". You must only have a single action registered for this tag.", MessageType.Warning);
|
||||
}
|
||||
break;
|
||||
|
||||
case TextAnimationActionState.RegistrationResult.NotRegistered:
|
||||
if (value.tagMode == TagMode.TextAnimatorOnlyTags)
|
||||
{
|
||||
break;
|
||||
}
|
||||
EditorGUILayout.HelpBox($"The tag mode is set to be {value.tagMode}, but {nameof(value.insertionAction)} is not registered with Text Animator. You must register the action to use this mode.", MessageType.Info);
|
||||
if (GUILayout.Button("Register action"))
|
||||
{
|
||||
TextAnimationActionState.RegisterAction(value.insertionAction);
|
||||
}
|
||||
break;
|
||||
|
||||
case TextAnimationActionState.RegistrationResult.Registered:
|
||||
if (value.tagMode == TagMode.TextAnimatorOnlyTags)
|
||||
{
|
||||
EditorGUILayout.HelpBox($"You have registered a Yarn Spinner action tag with Text Animator. This won't cause issues but is indicative of a configuration issue.", MessageType.Info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif !YS_USE_TEXT_ANIMATOR_3
|
||||
[CustomEditor(typeof(TextAnimatorYarnTypewriter))]
|
||||
public class TextAnimatorTypewriterEditor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox($"This package requires configuration before it can be used.", MessageType.Error);
|
||||
if (GUILayout.Button("Open Configuration Window"))
|
||||
{
|
||||
TextAnimatorConfigurationWindow.OpenWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75189881bc69a4f5da9a141b5624bc34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/TextAnimatorTypewriterEditor.cs
|
||||
uploadId: 968678
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "YarnSpinner.Addons.TextAnimatorIntegration.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:1e113d3b5d77bc04eab508251483e8ff",
|
||||
"GUID:e539678cf69674b418d82e89c16a9753",
|
||||
"GUID:34aa492b82754644eac2f903cd496268",
|
||||
"GUID:44199294ed9884553846d30d420ad69a",
|
||||
"GUID:3a299c53e4c683b4eb4a04c9ad9e648f",
|
||||
"UniTask"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33fdf84cdc6e643f8867a62469ab5024
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/YarnSpinner.Addons.TextAnimatorIntegration.Editor.asmdef
|
||||
uploadId: 968678
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 576 KiB |
+124
@@ -0,0 +1,124 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4bc00c6001e94d6d85534ee24530d57
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 0
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 1
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 267061
|
||||
packageName: Yarn Spinner+ for Unity, the friendly dialogue and narrative tool
|
||||
packageVersion: 3.2.8
|
||||
assetPath: Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/Editor/banner.jpg
|
||||
uploadId: 968678
|
||||
Reference in New Issue
Block a user