Brett
3 年前
当前提交
548ae699
共有 24 个文件被更改,包括 1731 次插入 和 0 次删除
-
8UOP1_Project/Assets/Scripts/Quests/Editor.meta
-
8UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages.meta
-
201UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages/BardHare.png
-
96UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages/BardHare.png.meta
-
231UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages/Earl.png
-
96UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages/Earl.png.meta
-
152UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages/FryKing.png
-
96UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages/FryKing.png.meta
-
246UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages/TownsFolk.png
-
96UOP1_Project/Assets/Scripts/Quests/Editor/ActorImages/TownsFolk.png.meta
-
16UOP1_Project/Assets/Scripts/Quests/Editor/DialogueLine.uxml
-
10UOP1_Project/Assets/Scripts/Quests/Editor/DialogueLine.uxml.meta
-
67UOP1_Project/Assets/Scripts/Quests/Editor/LocalizationUtils.cs
-
11UOP1_Project/Assets/Scripts/Quests/Editor/LocalizationUtils.cs.meta
-
289UOP1_Project/Assets/Scripts/Quests/Editor/QuestEditorWindow.cs
-
11UOP1_Project/Assets/Scripts/Quests/Editor/QuestEditorWindow.cs.meta
-
14UOP1_Project/Assets/Scripts/Quests/Editor/QuestEditorWindow.uss
-
11UOP1_Project/Assets/Scripts/Quests/Editor/QuestEditorWindow.uss.meta
-
39UOP1_Project/Assets/Scripts/Quests/Editor/QuestEditorWindow.uxml
-
10UOP1_Project/Assets/Scripts/Quests/Editor/QuestEditorWindow.uxml.meta
-
13UOP1_Project/Assets/Scripts/Quests/Editor/StepDetail.uxml
-
10UOP1_Project/Assets/Scripts/Quests/Editor/StepDetail.uxml.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 507502ee4be7b4545b63697baec6b895 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8455dd88edc59c844ba6f73a32c8ae5e |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5b0d4d0f220ebf84680ca4150537609b |
|||
TextureImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 11 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
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 |
|||
isReadable: 0 |
|||
streamingMipmaps: 0 |
|||
streamingMipmapsPriority: 0 |
|||
vTOnly: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -100 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
flipbookRows: 1 |
|||
flipbookColumns: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
ignorePngGamma: 0 |
|||
applyGammaDecoding: 0 |
|||
platformSettings: |
|||
- serializedVersion: 3 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
internalID: 0 |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
secondaryTextures: [] |
|||
spritePackingTag: |
|||
pSDRemoveMatte: 0 |
|||
pSDShowRemoveMatteOption: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: bb12fb6c85eb28e4fbcc9cd6164ea968 |
|||
TextureImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 11 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
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 |
|||
isReadable: 0 |
|||
streamingMipmaps: 0 |
|||
streamingMipmapsPriority: 0 |
|||
vTOnly: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -100 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
flipbookRows: 1 |
|||
flipbookColumns: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
ignorePngGamma: 0 |
|||
applyGammaDecoding: 0 |
|||
platformSettings: |
|||
- serializedVersion: 3 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
internalID: 0 |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
secondaryTextures: [] |
|||
spritePackingTag: |
|||
pSDRemoveMatte: 0 |
|||
pSDShowRemoveMatteOption: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 011a5bd942413db4ca21a7ad86f50ffb |
|||
TextureImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 11 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
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 |
|||
isReadable: 0 |
|||
streamingMipmaps: 0 |
|||
streamingMipmapsPriority: 0 |
|||
vTOnly: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -100 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
flipbookRows: 1 |
|||
flipbookColumns: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
ignorePngGamma: 0 |
|||
applyGammaDecoding: 0 |
|||
platformSettings: |
|||
- serializedVersion: 3 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
internalID: 0 |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
secondaryTextures: [] |
|||
spritePackingTag: |
|||
pSDRemoveMatte: 0 |
|||
pSDShowRemoveMatteOption: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1fa4bc8bdf03d5d41884e3dd50a1c1bd |
|||
TextureImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 11 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
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 |
|||
isReadable: 0 |
|||
streamingMipmaps: 0 |
|||
streamingMipmapsPriority: 0 |
|||
vTOnly: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -100 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
flipbookRows: 1 |
|||
flipbookColumns: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
ignorePngGamma: 0 |
|||
applyGammaDecoding: 0 |
|||
platformSettings: |
|||
- serializedVersion: 3 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
internalID: 0 |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
secondaryTextures: [] |
|||
spritePackingTag: |
|||
pSDRemoveMatte: 0 |
|||
pSDShowRemoveMatteOption: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> |
|||
<ui:VisualElement name="line-box" style="flex-direction: column; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px;"> |
|||
<ui:VisualElement name="lines" style="flex-direction: row; width: 100%;"> |
|||
<ui:VisualElement name="left-line" style="margin-left: 5px; margin-right: 5px; margin-top: 5px; margin-bottom: 5px; width: 50%; padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0;"> |
|||
<ui:Label text="This is line 1." display-tooltip-when-elided="true" name="left-line-label" style="background-color: rgb(158, 222, 115); white-space: normal;" /> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="right-line" style="width: 50%; margin-left: 5px; margin-right: 5px; margin-top: 5px; margin-bottom: 5px;"> |
|||
<ui:Label text="This is line 2." display-tooltip-when-elided="true" name="right-line-label" style="background-color: rgb(243, 145, 137); white-space: normal;" /> |
|||
</ui:VisualElement> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="buttons" style="flex-direction: row; justify-content: space-around;"> |
|||
<ui:Button text="Yes" name="btn-0" style="width: 45%; background-color: rgba(227, 253, 253, 255);" /> |
|||
<ui:Button text="No" name="btn-1" style="width: 45%; background-color: rgba(227, 253, 253, 255);" /> |
|||
</ui:VisualElement> |
|||
</ui:VisualElement> |
|||
</ui:UXML> |
|
|||
fileFormatVersion: 2 |
|||
guid: 943a041ff166ebb42bf97eb2c72af3cf |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
|
|||
using UnityEngine.Localization; |
|||
using UnityEngine.Localization.Tables; |
|||
|
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
using UnityEditor.Localization; |
|||
#endif
|
|||
|
|||
public static class LocalizationUtils |
|||
{ |
|||
#if UNITY_EDITOR
|
|||
|
|||
/// <summary>
|
|||
/// (Editor only)
|
|||
/// Gets a locale to use in edit mode in the editor.
|
|||
/// </summary>
|
|||
/// <param name="tableCollection">Optional table collection with which to filter the available locales.</param>
|
|||
/// <returns>The locale, null if none usable found.</returns>
|
|||
|
|||
static Locale Editor_GetValidLocaleInEditMode(LocalizationTableCollection tableCollection) |
|||
{ |
|||
foreach (var locale in LocalizationEditorSettings.GetLocales()) |
|||
{ |
|||
if (locale != null && (tableCollection == null || tableCollection.GetTable(locale.Identifier) != null)) |
|||
return locale; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
#endif
|
|||
|
|||
/// <summary>
|
|||
/// Gets the localized string from an already loaded table, taking into account whether we are in edit mode, play mode, or a build.
|
|||
/// </summary>
|
|||
/// <param name="localizedStringReference">The <see cref="LocalizedString"/>.</param>
|
|||
/// <returns>The localized string.</returns>
|
|||
|
|||
public static string GetLocalizedStringImmediateSafe(this LocalizedString localizedStringReference) |
|||
{ |
|||
// If we are in the editor in edit mode, we need to find a valid locale and get the localized string from it:
|
|||
#if UNITY_EDITOR
|
|||
{ |
|||
if (!EditorApplication.isPlaying) |
|||
{ |
|||
string text = null; |
|||
if (!localizedStringReference.IsEmpty) |
|||
{ |
|||
var tableCollection = LocalizationEditorSettings.GetStringTableCollection(localizedStringReference.TableReference); |
|||
Locale locale = Editor_GetValidLocaleInEditMode(tableCollection); |
|||
if (locale != null) |
|||
{ |
|||
StringTable table = (StringTable)tableCollection.GetTable(locale.Identifier); |
|||
if (table != null) |
|||
text = table.GetEntryFromReference(localizedStringReference.TableEntryReference).LocalizedValue; |
|||
} |
|||
} |
|||
|
|||
return text; |
|||
} |
|||
} |
|||
#endif
|
|||
|
|||
// At runtime (build or editor in play mode), we just get the localized string normally:
|
|||
return localizedStringReference.GetLocalizedString().Result; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f26196594cec4f84f8f5b31c933a683e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using UnityEngine.UIElements; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.Localization; |
|||
|
|||
public class QuestEditorWindow : EditorWindow |
|||
{ |
|||
private Image actorPreview; |
|||
private QuestSO currentSeletedQuest; |
|||
|
|||
[MenuItem("ChopChop/QuestEditorWindow")] |
|||
public static void ShowWindow() |
|||
{ |
|||
QuestEditorWindow wnd = GetWindow<QuestEditorWindow>(); |
|||
wnd.titleContent = new GUIContent("QuestEditorWindow"); |
|||
} |
|||
|
|||
public void CreateGUI() |
|||
{ |
|||
VisualElement root = rootVisualElement; |
|||
|
|||
// Import UXML
|
|||
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Scripts/Quests/Editor/QuestEditorWindow.uxml"); |
|||
root.Add(visualTree.CloneTree()); |
|||
|
|||
//Add Image
|
|||
VisualElement preview = root.Q<VisualElement>("actor-preview"); |
|||
actorPreview = new Image(); |
|||
preview.Add(actorPreview); |
|||
|
|||
//Import USS
|
|||
var styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Scripts/Quests/Editor/QuestEditorWindow.uss"); |
|||
root.styleSheets.Add(styleSheet); |
|||
|
|||
//Register button event
|
|||
Button refreshQuestPreviewBtn = root.Q<Button>("refresh-preview-btn"); |
|||
refreshQuestPreviewBtn.RegisterCallback<ClickEvent>((evt) => SetUpQuestPreview(currentSeletedQuest)); |
|||
|
|||
LoadAllQuestsData(); |
|||
} |
|||
|
|||
private void LoadAllQuestsData() |
|||
{ |
|||
//Load all questlines
|
|||
FindAllSOByType(out QuestlineSO[] questLineSOs); |
|||
RefreshListView(out ListView allQuestlinesListView, "questlines-list", questLineSOs); |
|||
|
|||
allQuestlinesListView.onSelectionChanged += (questlineEnumerable) => |
|||
{ |
|||
QuestlineSO questLine = GetDataFromListViewItem<QuestlineSO>(questlineEnumerable); |
|||
RefreshListView(out ListView allQuestsListView, "quests-list", questLine.Quests.ToArray()); |
|||
|
|||
allQuestsListView.onSelectionChanged += (questEnumerable) => |
|||
{ |
|||
currentSeletedQuest = GetDataFromListViewItem<QuestSO>(questEnumerable); |
|||
RefreshListView(out ListView allStepsListView, "steps-list",currentSeletedQuest.Steps.ToArray() ); |
|||
|
|||
SetUpQuestPreview(currentSeletedQuest); |
|||
|
|||
allStepsListView.onSelectionChanged += (stepEnumerable) => |
|||
{ |
|||
StepSO step = GetDataFromListViewItem<StepSO>(stepEnumerable); |
|||
DisplayAllProperties(step, "step-info-scroll"); |
|||
|
|||
//Find all DialogueDataSOs in the same folder of the StepSO
|
|||
FindAllSOsInTargetFolder(step, out DialogueDataSO[] dialogueDataSOs); |
|||
RefreshListView(out ListView dialoguesListView, "dialogues-list", dialogueDataSOs); |
|||
|
|||
dialoguesListView.onSelectionChanged += (dialogueEnumerable) => |
|||
{ |
|||
DialogueDataSO dialogueData = GetDataFromListViewItem<DialogueDataSO>(dialogueEnumerable); |
|||
DisplayAllProperties(dialogueData, "dialogue-info-scroll"); |
|||
}; |
|||
}; |
|||
}; |
|||
}; |
|||
} |
|||
|
|||
private T GetDataFromListViewItem<T>(List<object> enumberable) where T : class |
|||
{ |
|||
T data = default; |
|||
foreach (var item in enumberable) |
|||
{ |
|||
data = item as T; |
|||
} |
|||
return data; |
|||
} |
|||
|
|||
private void SetUpQuestPreview(QuestSO quest) |
|||
{ |
|||
if (quest != null) |
|||
{ |
|||
LoadActorImage(quest.Steps[0].Actor.name); |
|||
|
|||
//Clear actor conversations area
|
|||
VisualElement actorConversationsVE = rootVisualElement.Q<VisualElement>("actor-conversations"); |
|||
actorConversationsVE.Clear(); |
|||
|
|||
foreach (StepSO step in quest.Steps) |
|||
{ |
|||
LoadAndInitStepUXML(step); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private void LoadAndInitStepUXML(StepSO step) |
|||
{ |
|||
//Clear actor conversations area
|
|||
VisualElement actorConversationsVE = rootVisualElement.Q<VisualElement>("actor-conversations"); |
|||
|
|||
// Import UXML
|
|||
var stepVisualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Scripts/Quests/Editor/StepDetail.uxml"); |
|||
VisualElement stepVE = stepVisualTree.CloneTree(); |
|||
VisualElement dialogueAreaVE = stepVE.Q<VisualElement>("dialogue-area"); |
|||
|
|||
//Title
|
|||
stepVE.Q<Label>("step-title-label").text = "Step" + step.name[1]; |
|||
|
|||
//IsDone
|
|||
Toggle isDoneToggle = stepVE.Q<Toggle>("step-done-toggle"); |
|||
isDoneToggle.value = step.IsDone; |
|||
isDoneToggle.SetEnabled(false); |
|||
|
|||
//SD
|
|||
LoadAndInitStartDialogueLineUXML(step.DialogueBeforeStep, dialogueAreaVE); |
|||
|
|||
//CD ID if any
|
|||
if (step.CompleteDialogue != null) |
|||
LoadAndInitOptionsDialogueLineUXML(step.CompleteDialogue, step.IncompleteDialogue, dialogueAreaVE); |
|||
|
|||
//Type (Check Item etc)
|
|||
if (step.Type == stepType.dialogue) |
|||
{ |
|||
VisualElement itemValidateVE = stepVE.Q<VisualElement>("item-validate"); |
|||
itemValidateVE.style.display = DisplayStyle.None; |
|||
} |
|||
else |
|||
{ |
|||
stepVE.Q<Label>("step-type").text = step.Type + ":"; |
|||
if (step.Item != null) |
|||
stepVE.Q<Label>("item-to-validate").text = step.Item.ToString(); |
|||
} |
|||
|
|||
actorConversationsVE.Add(stepVE); |
|||
} |
|||
|
|||
private void LoadAndInitStartDialogueLineUXML(DialogueDataSO startDialogue, VisualElement parent) |
|||
{ |
|||
// Import UXML
|
|||
var dialogueVisualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Scripts/Quests/Editor/DialogueLine.uxml"); |
|||
|
|||
// Set line
|
|||
foreach (LocalizedString line in startDialogue.DialogueLines) |
|||
{ |
|||
VisualElement dialogueVE = dialogueVisualTree.CloneTree(); |
|||
|
|||
Label leftLineLabel = dialogueVE.Q<Label>("left-line-label"); |
|||
leftLineLabel.text = line.GetLocalizedStringImmediateSafe(); |
|||
|
|||
Label rightLineLabel = dialogueVE.Q<Label>("right-line-label"); |
|||
rightLineLabel.style.display = DisplayStyle.None; |
|||
|
|||
// Set options
|
|||
VisualElement buttonArea = dialogueVE.Q<VisualElement>("buttons"); |
|||
if (startDialogue.Choices.Count==0) |
|||
{ |
|||
buttonArea.style.display = DisplayStyle.None; |
|||
} |
|||
else if (startDialogue.Choices.Count <= 2) |
|||
{ |
|||
for (int i = 0; i < 2; i++) |
|||
{ |
|||
Button btn = buttonArea.Q<Button>($"btn-{i}"); |
|||
if (i < startDialogue.Choices.Count) |
|||
btn.text = startDialogue.Choices[i].Response.GetLocalizedStringImmediateSafe(); |
|||
else |
|||
btn.style.display = DisplayStyle.None; |
|||
} |
|||
} |
|||
parent.Add(dialogueVE); |
|||
} |
|||
} |
|||
|
|||
private void LoadAndInitOptionsDialogueLineUXML(DialogueDataSO completeDialogue, DialogueDataSO incompleteDialogue, VisualElement parent) |
|||
{ |
|||
// Import UXML
|
|||
var dialogueVisualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Scripts/Quests/Editor/DialogueLine.uxml"); |
|||
VisualElement dialogueVE = dialogueVisualTree.CloneTree(); |
|||
|
|||
// Set line
|
|||
Label leftLineLabel = dialogueVE.Q<Label>("left-line-label"); |
|||
Label rightLineLabel = dialogueVE.Q<Label>("right-line-label"); |
|||
|
|||
leftLineLabel.text = completeDialogue.DialogueLines[0].GetLocalizedStringImmediateSafe(); |
|||
if (incompleteDialogue != null) |
|||
rightLineLabel.text = incompleteDialogue.DialogueLines[0].GetLocalizedStringImmediateSafe(); |
|||
|
|||
// hide options
|
|||
VisualElement buttonArea = dialogueVE.Q<VisualElement>("buttons"); |
|||
buttonArea.style.display = DisplayStyle.None; |
|||
|
|||
parent.Add(dialogueVE); |
|||
} |
|||
|
|||
private void FindAllSOsInTargetFolder<T>(Object target, out T[] foundSOs) where T : Object |
|||
{ |
|||
var guids = AssetDatabase.FindAssets($"t:{typeof(T)}", new[] {Path.GetDirectoryName(AssetDatabase.GetAssetPath(target))}); |
|||
|
|||
foundSOs = new T[guids.Length]; |
|||
for (int i = 0; i < guids.Length; i++) |
|||
{ |
|||
var path = AssetDatabase.GUIDToAssetPath(guids[i]); |
|||
foundSOs[i] = AssetDatabase.LoadAssetAtPath<T>(path); |
|||
} |
|||
} |
|||
|
|||
private void FindAllSOByType<T>(out T[] foundSOs) where T : Object //bug: if I wrote "ScriptableObject", it doesn't work.
|
|||
{ |
|||
var guids = AssetDatabase.FindAssets($"t:{typeof(T)}"); |
|||
|
|||
foundSOs = new T[guids.Length]; |
|||
for (int i = 0; i < guids.Length; i++) |
|||
{ |
|||
var path = AssetDatabase.GUIDToAssetPath(guids[i]); |
|||
foundSOs[i] = AssetDatabase.LoadAssetAtPath<T>(path); |
|||
} |
|||
} |
|||
|
|||
private void InitListView<T>(ListView listview, T[] itemsSource) |
|||
{ |
|||
listview.makeItem = () => new Label(); |
|||
listview.bindItem = (element, i) => |
|||
{ |
|||
var nameProperty = itemsSource[i].GetType().GetProperty("name"); |
|||
if (nameProperty != null) |
|||
{ |
|||
(element as Label).text = nameProperty.GetValue(itemsSource[i]) as string; |
|||
} |
|||
}; |
|||
listview.itemsSource = itemsSource; |
|||
listview.itemHeight = 16; |
|||
listview.selectionType = SelectionType.Single; |
|||
listview.style.flexGrow = 1.0f; |
|||
|
|||
listview.Refresh(); |
|||
listview.selectedIndex = 0; |
|||
} |
|||
|
|||
private void RefreshListView<T>(out ListView listview, string visualElementName, T[] itemsSource) |
|||
{ |
|||
listview = new ListView(); |
|||
VisualElement parentVE = rootVisualElement.Q<VisualElement>(visualElementName); |
|||
parentVE.Clear(); |
|||
InitListView(listview, itemsSource); |
|||
parentVE.Add(listview); |
|||
} |
|||
|
|||
private void LoadActorImage(string actorName) |
|||
{ |
|||
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath($"Assets/Scripts/Quests/Editor/ActorImages/{actorName}.png", typeof(Texture2D)); |
|||
actorPreview.image = texture; |
|||
} |
|||
|
|||
private void DisplayAllProperties(Object data, string visualElementName) |
|||
{ |
|||
//Clear panel
|
|||
VisualElement parentVE = rootVisualElement.Q<VisualElement>(visualElementName); |
|||
parentVE.Clear(); |
|||
|
|||
//Add new scrollview
|
|||
ScrollView scrollView= new ScrollView(); |
|||
|
|||
SerializedObject dataObject = new SerializedObject(data); |
|||
SerializedProperty dataProperty = dataObject.GetIterator(); |
|||
dataProperty.Next(true); |
|||
|
|||
while (dataProperty.NextVisible(false)) |
|||
{ |
|||
PropertyField prop=new PropertyField(dataProperty); |
|||
prop.SetEnabled(dataProperty.name != "m_Script"); |
|||
prop.Bind(dataObject); |
|||
scrollView.Add(prop); |
|||
} |
|||
parentVE.Add(scrollView); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1f7d33e8ca98ba74c884ccd68de073f2 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
.title { |
|||
-unity-font-style: bold; |
|||
font-size: 15px; |
|||
-unity-text-align: upper-center; |
|||
margin-top: 5px; |
|||
margin-bottom: 5px; |
|||
} |
|||
|
|||
.padding5 { |
|||
padding-left: 5px; |
|||
padding-right: 5px; |
|||
padding-top: 5px; |
|||
padding-bottom: 5px; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: cce29b5de6a119941a65b3c3a7f2b3c5 |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} |
|||
disableValidation: 0 |
|
|||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> |
|||
<Style src="QuestEditorWindow.uss" /> |
|||
<ui:VisualElement name="quest-editor-window" style="flex-direction: row; height: 100%; width: 100%; min-height: 700px;"> |
|||
<ui:VisualElement name="1st-column" style="width: 30%;"> |
|||
<ui:VisualElement name="questlines" class="padding5" style="width: auto; background-color: rgb(227, 253, 253); height: 150px;"> |
|||
<ui:Label text="Questlines" display-tooltip-when-elided="true" name="title-questline" class="title" /> |
|||
<ui:VisualElement name="questlines-list" style="height: 100%;" /> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="steps" class="padding5" style="width: auto; background-color: rgb(203, 241, 245); height: 150px;"> |
|||
<ui:Label text="Steps" display-tooltip-when-elided="true" name="title-step" class="title" /> |
|||
<ui:VisualElement name="steps-list" style="height: 100%;" /> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="step-info-panel" class="padding5" style="width: auto; background-color: rgb(227, 253, 253); height: 100%;"> |
|||
<ui:Label text="Step Info" display-tooltip-when-elided="true" name="step-info" class="title" /> |
|||
<ui:VisualElement name="step-info-scroll" style="height: 100%;" /> |
|||
</ui:VisualElement> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="2nd-column" style="width: 30%;"> |
|||
<ui:VisualElement name="quests" class="padding5" style="width: auto; background-color: rgb(203, 241, 245); height: 150px;"> |
|||
<ui:Label text="Quests" display-tooltip-when-elided="true" name="title-quest" class="title" /> |
|||
<ui:VisualElement name="quests-list" style="height: 100%;" /> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="dialogues" class="padding5" style="width: auto; background-color: rgb(227, 253, 253); height: 150px;"> |
|||
<ui:Label text="Dialogues" display-tooltip-when-elided="true" name="title-dislogues" class="title" /> |
|||
<ui:VisualElement name="dialogues-list" style="height: 100%;" /> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="dialogue-info-panel" class="padding5" style="width: auto; background-color: rgb(203, 241, 245); height: 100%;"> |
|||
<ui:Label text="Dialogue Info" display-tooltip-when-elided="true" name="dialogue-info" class="title" /> |
|||
<ui:VisualElement name="dialogue-info-scroll" style="height: 100%;" /> |
|||
</ui:VisualElement> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="3rd-column" style="width: 40%; background-color: rgb(113, 201, 206);"> |
|||
<ui:Label text="Quest Preview" display-tooltip-when-elided="true" name="quest-preview-title" class="title" /> |
|||
<ui:Button text="Refresh" display-tooltip-when-elided="true" name="refresh-preview-btn" style="width: 100px; margin-left: auto; margin-right: 1px; background-color: rgba(203, 241, 245, 255);" /> |
|||
<ui:VisualElement name="actor-preview" style="width: 100px; height: 100px; margin-left: auto; margin-right: auto;" /> |
|||
<ui:VisualElement name="actor-conversations" style="padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px;" /> |
|||
</ui:VisualElement> |
|||
</ui:VisualElement> |
|||
</ui:UXML> |
|
|||
fileFormatVersion: 2 |
|||
guid: 09fbee9515eb570468419eb0f1a1804c |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
|
|||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> |
|||
<ui:VisualElement name="step-detail-box" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); background-color: rgba(166, 227, 233, 255); border-top-left-radius: 5px; border-bottom-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; margin-left: 3px; margin-right: 3px; margin-top: 3px; margin-bottom: 3px;"> |
|||
<ui:VisualElement name="step-title-box" style="border-bottom-color: rgb(0, 0, 0); border-bottom-width: 1px; flex-direction: row; justify-content: space-between;"> |
|||
<ui:Label text="Step1" display-tooltip-when-elided="true" name="step-title-label" style="-unity-font-style: bold;" /> |
|||
<ui:Toggle name="step-done-toggle" text="IsDone" value="false" style="-unity-font-style: normal;" /> |
|||
</ui:VisualElement> |
|||
<ui:VisualElement name="dialogue-area" /> |
|||
<ui:VisualElement name="item-validate" style="flex-direction: row; justify-content: space-around;"> |
|||
<ui:Label text="Check Item:" display-tooltip-when-elided="true" name="step-type" style="-unity-font-style: bold;" /> |
|||
<ui:Label text="Apple" display-tooltip-when-elided="true" name="item-to-validate" /> |
|||
</ui:VisualElement> |
|||
</ui:VisualElement> |
|||
</ui:UXML> |
|
|||
fileFormatVersion: 2 |
|||
guid: 0287ae8d733ceec489be8851ae26c774 |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
撰写
预览
正在加载...
取消
保存
Reference in new issue