2016-12-06 1 views
0

Unity v5.0でUnity v4で作成されたアセットを使用しようとしています。インポートを実行した後、私はさまざまな「古い」エラーを修正しましたが、私は周りを回っているようには見えません。Unity Asset error - 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){ 
     // ... 
    } 
} 

答えて

1

(あなたは便宜上、これを処理するために拡張メソッドを書くことができますが)あなたはUndo.RecordObject()に直接配列を渡すことはできません。ここでは最も簡単な方法は、childNodesを通じてだけでループしているとUndo.RecordObject()ViNodeの各インスタンスを渡します

if(GUILayout.Button("ReIndexChildren")){ 
    ViNode[] childNodes = node.GetComponentsInChildren<ViNode>(); 

    foreach (ViNode childNode in childNodes){ 
     Undo.RecordObject(childNode, "ReIndexChildren"); 
    } 

    node.ReIndexChildren(); 
} 
+0

こんにちは、ありがとう。完璧に動作します。質問を編集していただきありがとうございます。次回質問を投稿するときにこのフォーマットを覚えておきます。 –

+0

@ M-Corp素晴らしい、私はあなたを助けることができてうれしい!あなたが答えに満足しているなら、それを受け入れるためにそれの横のチェックマークをクリックすることができます - これは誰にも質問が解決されたことを伝えます。 – Serlite

関連する問題