2016-11-02 19 views
0

カスタムエディタを作成する前に問題はありませんでしたが、このスクリプトでは「マルチオブジェクト編集はサポートされていません」と伝えられているようです。私のカスタムエディタ用のスクリプト。私が紛失しているものがありますか?カスタムエディタ - マルチオブジェクト編集はサポートされていません

using UnityEngine; 
using UnityEngine.UI; 
using System.Collections; 
using System.Collections.Generic; 

[AddComponentMenu("Biophase Games/UI/Togglr")] 
[System.Serializable] 
public class Togglr : MonoBehaviour { 

    public List<Toggler> toggles; 

    public ColorBlock onColors; 
    public ColorBlock offColors; 

    public string value; 

    void Update() { 

     foreach(Toggler t in toggles) { 

      if (t.toggle.isOn == true) { 

       value = t.text; 

       t.toggle.colors = onColors; 

      } else { 

       t.toggle.colors = offColors; 

      } 

     } 

    } 

} 

[System.Serializable] 
public class Toggler { 

    public Toggle toggle; 
    public string text; 

} 

とCustomEditorスクリプト

using UnityEngine; 
using UnityEngine.UI; 
using UnityEditor; 
using System.Collections; 
using System.Collections.Generic; 

[CustomEditor(typeof(Togglr))] 
[CanEditMultipleObjects] 
public class TogglrEditor : Editor { 

    SerializedProperty onColors; 
    SerializedProperty offColors; 
    SerializedProperty toggles; 

    void OnEnable() { 

     onColors = serializedObject.FindProperty ("onColors"); 
     offColors = serializedObject.FindProperty ("offColors"); 
     toggles = serializedObject.FindProperty ("toggles"); 

    } 

    public override void OnInspectorGUI() { 

     serializedObject.Update(); 

     EditorGUILayout.PropertyField (toggles, true); 
     EditorGUILayout.PropertyField (onColors); 
     EditorGUILayout.PropertyField (offColors); 

     serializedObject.ApplyModifiedProperties(); 

    } 

} 

答えて

0

私の問題を解決するための試みで、私はその後、私が持っていた問題を解決し、それ自身のファイルにクラストグラーを移動しました。

関連する問題