0
我嘗試使用Unity v5.0中Unity v4中創建的資產。進行導入後,我修復了各種「過時」的錯誤,但我似乎無法解決。統一資產錯誤 - 無法在Unity 5中加載Unity 4資產時從'ViNode []'轉換爲'UnityEngine.Object'
我得到的錯誤是:
無法轉換from'ViNode []」到 'UnityEngine.Object'
這個錯誤出現在該行:
Undo.RecordObject(childNodes, "ReIndexChildren");"
我需要將childNodes
轉換爲GameObject嗎?或者,我可以在這裏使用Undo.RecordObject()
的替代方案嗎?
下面是資產代碼:
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using ViNoToolkit;
using System.Collections;
/// <summary>
/// Draw NodeI .
/// </summary>
static public class NodeGUI{
static private int k_PositionEntryNum = 5;
/// <summary>
/// Raises the GUI selection unit event.
/// </summary>
/// <param name="unit">Unit.</param>
static public void OnGUISelectionUnit(SelectionsNode.SelectUnit unit){
// ...
}
/// <summary>
/// Raises the GUI ViNode event.
/// </summary>
/// <param name="node">Node.</param>
/// <param name="drawChildList">If set to <c>true</c> draw child list.</param>
/// <param name="showNextNode">If set to <c>true</c> show next node.</param>
static public void OnGUI_ViNode(GameObject[] objs, ViNode node , bool drawChildList , bool showNextNode)
{
GUICommon.DrawLineSpace(7f , 7f);
bool hasViNode = false;
if(drawChildList){
Color savedCol = GUI.color;
GUI.color = Color.green;
int childCount= node.transform.childCount ;
for(int i=0;i<childCount;i++){
Transform childTra = node.transform.GetChild(i);
ViNode vinode = childTra.GetComponent<ViNode>();
if(vinode != null){
hasViNode = true;
Undo.RecordObject(childTra.gameObject , "active" + childTra.name);
EditorGUILayout.BeginHorizontal();
// bool t = EditorGUILayout.Toggle(childTra.gameObject.activeInHierarchy , GUILayout.Width(10f));
// Toggle active.
if(GUILayout.Button(i.ToString() , GUILayout.Width (20f))){
childTra.gameObject.SetActive(! childTra.gameObject.activeInHierarchy );
}
GUI.enabled = childTra.gameObject.activeInHierarchy;
if(GUILayout.Button (childTra.name)){
EditorGUIUtility.PingObject(childTra.gameObject);
if(Application.isPlaying){
VM.Instance.GoToLabel(vinode.GetNodeLabel());
}
}
GUI.enabled = true;
EditorGUILayout.EndHorizontal();
}
}
GUI.color = savedCol;
}
if(hasViNode){
EditorGUILayout.LabelField("When execution order is not right in Children,");
EditorGUILayout.LabelField("Please push RefreshChildren button to fix.");
EditorGUILayout.BeginHorizontal();
if(GUILayout.Button("RefreshChildren")){
node.RefreshChildren();
}
if(GUILayout.Button("ReIndexChildren")){
ViNode[] childNodes = node.GetComponentsInChildren<ViNode>();
Undo.RecordObject(childNodes, "ReIndexChildren");
node.ReIndexChildren();
}
EditorGUILayout.EndHorizontal();
}
GUICommon.DrawLineSpace(5f , 5f);
}
static public void DrawItemBarBackground(){
// ...
}
static public void DrawDialogItemBar(DialogPartNode node , ref DialogPartData unit , int index , ViNoTextBox textBox , ViNoTextBox nameTextBox){
// ...
}
static public void DrawEnterActorActionsView( DialogPartNode node , ref DialogPartData unit){
// ...
}
/// <summary>
/// Draws the action view mode.
/// </summary>
/// <param name="action">Action.</param>
/// <param name="node">Node.</param>
/// <param name="unit">Unit.</param>
/// <param name="index">Index.</param>
/// <param name="textBox">Text box.</param>
/// <param name="nameTextBox">Name text box.</param>
static public void DrawActionViewMode(DialogPartNodeActionType action , DialogPartNode node , ref DialogPartData unit , int index , ViNoTextBox textBox , ViNoTextBox nameTextBox){
// ...
}
static public void DrawEditTextViewMode(DialogPartNodeActionType action , DialogPartNode node , ref DialogPartData unit , int index , ViNoTextBox textBox , ViNoTextBox nameTextBox){
// ...
}
static public void OnGUI_a(DialogPartNode node , ref DialogPartData unit , int index , ViNoTextBox textBox , ViNoTextBox nameTextBox , int viewMode){
// ...
}
static public void DrawLayoutEnterActorField(DialogPartData unit){
// ...
}
static public void DrawLayoutExitActorField(DialogPartData unit){
// ...
}
static public void DrawLayoutChangeStateActorField(DialogPartData unit){
// ...
}
static public void DrawLayoutSceneField(DialogPartData unit){
// ...
}
/// <summary>
/// Draws the layout name field.
/// </summary>
/// <param name="unit">Unit.</param>
static public void DrawLayoutNameField(DialogPartData unit){
// ...
}
/// <summary>
/// Draws the layout dialog text field.
/// </summary>
/// <param name="unit">Unit.</param>
static public void DrawLayoutDialogTextField(DialogPartData unit){
// ...
}
}
您好,感謝。完美的作品。感謝您編輯該問題。我將在下次發佈問題時記住這種格式。 –
@ M-Corp太棒了,很高興我能幫助你!如果您對答案滿意,您可以點擊旁邊的複選標記來接受它 - 這告訴大家問題已經解決。 – Serlite