【发布时间】:2015-01-19 00:15:47
【问题描述】:
我正在尝试更改已保存为预制件的对话框 UI(Unity 4.6 的 UI)中嵌套图像对象的精灵。我可以加载预制件,但是当我尝试这样做时:
Image[] imageComponents = conversationDialogNoChoice.GetComponentsInChildren<Image>();
我得到零件。层次结构是:
完整代码为:
private GameObject conversationDialogNoChoice;
public void StartConversation(Conversation conversation)
{
if (!talking)
{
//StartCoroutine(DisplayConversation(conversation));
StartCoroutine(DisplayConversation(conversation));
}
}
IEnumerator DisplayConversationNewUI(Conversation conversation)
{
conversationDialogNoChoice = (GameObject)Resources.Load("Prefabs/ConversationDialogNoChoices");
conversationDialogChoice = (GameObject)Resources.Load("Prefabs/ConversationDialogChoices");
ConversationTest = (GameObject)Resources.Load("Prefabs/ConversationTest");
bool nextPushed;
foreach (var conversationLine in conversation.ConversationLines)
{
nextPushed = false;
Image[] imageComponents = conversationDialogNoChoice.GetComponentsInChildren<Image>();
Debug.Log(imageComponents.Length);
//imageComponents[].sprite = currentCovnersationLine.DisplayPicture;
Instantiate(conversationDialogNoChoice);
while (!nextPushed)
{
if (Input.GetKeyDown(KeyCode.Return))
{
nextPushed = true;
}
yield return null;
}
}
talking = false; //talking is complete
if (conversation.Repeatable == false)
{
conversation.CanOccur = false;
}
yield return null;
}
【问题讨论】:
标签: unity3d unityscript unity3d-gui