按名称索引子物体
This commit is contained in:
@@ -421,14 +421,14 @@ RectTransform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 429395226}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1299926725}
|
||||
- {fileID: 1696845842}
|
||||
m_Father: {fileID: 984233631}
|
||||
m_Father: {fileID: 1788453626}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
@@ -1391,7 +1391,6 @@ RectTransform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 731599308}
|
||||
- {fileID: 429395227}
|
||||
m_Father: {fileID: 1343879457}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
@@ -1711,7 +1710,7 @@ Transform:
|
||||
m_Children:
|
||||
- {fileID: 1604842429}
|
||||
- {fileID: 984233631}
|
||||
- {fileID: 1655147933}
|
||||
- {fileID: 1788453626}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1557925019
|
||||
@@ -2506,11 +2505,11 @@ Transform:
|
||||
m_GameObject: {fileID: 1655147930}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -748.1581, y: -442.48004, z: 11.807568}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1343879457}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1696845841
|
||||
GameObject:
|
||||
@@ -2577,6 +2576,108 @@ MonoBehaviour:
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!1 &1788453625
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1788453626}
|
||||
- component: {fileID: 1788453629}
|
||||
- component: {fileID: 1788453628}
|
||||
- component: {fileID: 1788453627}
|
||||
m_Layer: 0
|
||||
m_Name: Menu Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1788453626
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1788453625}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 429395227}
|
||||
m_Father: {fileID: 1343879457}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!114 &1788453627
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1788453625}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &1788453628
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1788453625}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
--- !u!223 &1788453629
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1788453625}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!1 &1936621684
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2747,3 +2848,4 @@ SceneRoots:
|
||||
- {fileID: 619394802}
|
||||
- {fileID: 1343879457}
|
||||
- {fileID: 1009826577}
|
||||
- {fileID: 1655147933}
|
||||
|
||||
@@ -13,20 +13,20 @@ namespace AibisDream.Test
|
||||
|
||||
void Start()
|
||||
{
|
||||
// 初始化时注册Command
|
||||
// 第一个参数为[command name=xxx]的参数
|
||||
// 第二个参数是注册的函数,在Yarn走到选择项时触发
|
||||
// 初始化时注册Command
|
||||
// 第一个参数为[command name=xxx]的参数
|
||||
// 第二个参数是注册的函数,在Yarn走到选择项时触发
|
||||
DialogController.Instance.RegisterOptionCommand("show_buttons", ShowButtons);
|
||||
|
||||
// 不重要
|
||||
// 不重要
|
||||
panel = transform.GetChild(0).gameObject;
|
||||
prefab = Resources.Load<GameObject>("Perfabs/UI/Choice Button");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册的命令
|
||||
/// 注册的命令
|
||||
/// </summary>
|
||||
/// <param name="options">触发时提供的选择项</param>
|
||||
/// <param name="options">触发时提供的选择项</param>
|
||||
public void ShowButtons(YarnOption[] options)
|
||||
{
|
||||
foreach (YarnOption option in options)
|
||||
@@ -37,7 +37,7 @@ namespace AibisDream.Test
|
||||
|
||||
instance.GetComponent<Button>().onClick.AddListener(() => {
|
||||
|
||||
// 执行SelectOption(), 对话就会从对应的选项往下继续执行
|
||||
// 执行SelectOption(), 对话就会从对应的选项往下继续执行
|
||||
option.SelectOption();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace AibisDream.Test
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
// 注意在合适的时机移除命令
|
||||
// 注意在合适的时机移除命令
|
||||
DialogController.Instance.RemoveOptionCommand("show_buttons");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using Febucci.UI;
|
||||
using Febucci.UI.Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -12,6 +9,14 @@ namespace AibisDream
|
||||
{
|
||||
public class DialogUiViewer : Singleton<DialogUiViewer>
|
||||
{
|
||||
#region 组件名称
|
||||
private const string DIALOG_BOX = "Dialog Box";
|
||||
private const string ACTOR_NAME = "Actor Name";
|
||||
private const string DIALOG_TEXT = "Dialog Text";
|
||||
private const string NEXT_BUTTON = "Next Button";
|
||||
private const string CHOICE_BUTTON = "Choice Button";
|
||||
#endregion
|
||||
|
||||
#region 对话框UI
|
||||
private GameObject dialogBox;
|
||||
private TypewriterByCharacter dialogText;
|
||||
@@ -27,8 +32,7 @@ namespace AibisDream
|
||||
// 获取预制体
|
||||
choiceButtonPrefab = Resources.Load<GameObject>("Perfabs/UI/Choice Button");
|
||||
// 获取子物体
|
||||
dialogBox = transform.GetChild(0).gameObject;
|
||||
Debug.Log(dialogBox == null);
|
||||
dialogBox = transform.Find(DIALOG_BOX).gameObject;
|
||||
GetDialogComponentInBox(dialogBox);
|
||||
}
|
||||
|
||||
@@ -87,10 +91,10 @@ namespace AibisDream
|
||||
|
||||
private void GetDialogComponentInBox(GameObject box)
|
||||
{
|
||||
actorName = box.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>();
|
||||
dialogText = box.transform.GetChild(1).gameObject.GetComponent<TypewriterByCharacter>();
|
||||
nextButton = box.transform.GetChild(2).GetComponent<Button>();
|
||||
choiceBox = box.transform.GetChild(3).gameObject;
|
||||
actorName = box.transform.Find(ACTOR_NAME).gameObject.GetComponent<TextMeshProUGUI>();
|
||||
dialogText = box.transform.Find(DIALOG_TEXT).gameObject.GetComponent<TypewriterByCharacter>();
|
||||
nextButton = box.transform.Find(NEXT_BUTTON).GetComponent<Button>();
|
||||
choiceBox = box.transform.Find(CHOICE_BUTTON).gameObject;
|
||||
|
||||
dialogText.onTextShowed.AddListener(ShowNextButton);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user