示例#1
0
        static UnityEngine.Object[] bindableObjects; // = new List<Behaviour>();
        public override void OnInspectorGUI()
        {
            // base.OnInspectorGUI ();
            EditorGUILayout.Separator();

            EditorGUILayout.LabelField("Drag(BindableObject) to add", GUILayout.Width(200));
            EditorGUILayout.Space();
            UnityEngine.Component addComponent = null;
            addComponent = (UnityEngine.Component)EditorGUILayout.ObjectField(addComponent, typeof(UnityEngine.Component), true, GUILayout.Height(40));

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Bindable List", GUILayout.Width(200));
            EditorGUILayout.Space();

            var temp = target as BindableContainer;

            Undo.RecordObject(target, "F");
            BindableObject objComponent;

            if (temp.children != null)
            {
                for (int i = 0; i < temp.children.Count; i++)
                {
                    // EditorGUILayout.BeginHorizontal ();
                    // GUILayout.Label ((i + 1).ToString (), GUILayout.Width (20));
                    objComponent = temp.children[i];
                    // EditorGUILayout.ObjectField (objComponent, typeof (UnityEngine.Object));
                    // objComponent = PopupGameObjectComponents (GetbindableObjects (temp, i).target, i); //选择绑定的component type类型
                    // if (objComponent != null) AddbindableObjects (temp, i, objComponent); //绑定选中的类型
                    // //显示选中的对象
                    // AddbindableObjects (temp, i, EditorGUILayout.ObjectField (GetbindableObjects (temp, i).target, typeof (UnityEngine.Object), true, GUILayout.MaxWidth (80)));
                    // //选择可绑定属性
                    // PopupComponentsProperty (temp, i);
                    BindableObjectHelper.BindableObjectField(objComponent, i);
                    if (GUILayout.Button("Del", GUILayout.Width(30)))
                    {
                        RemoveAtbindableObjects(temp, i);
                    }

                    // EditorGUILayout.EndHorizontal ();
                    //设置binding属性
                    SetBindingProperties(temp, i);
                    EditorGUILayout.Space();
                }
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();

            if (addComponent)
            {
                AddbindableObjects(temp, addComponent);  //allcomps[allcomps.Length - 1]);
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndHorizontal();

            //EditorUtility.SetDirty (target);
        }
示例#2
0
        public override void OnInspectorGUI()
        {
            // base.OnInspectorGUI ();
            EditorGUILayout.Separator();
            var temp = target as BindableObject;

            // GUILayout.Label ((index).ToString (), GUILayout.Width (20));
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("target:", GUILayout.Width(40));
            temp.target = EditorGUILayout.ObjectField(temp.target, typeof(UnityEngine.Object), GUILayout.MaxWidth(150));    //显示绑定对象
            EditorGUILayout.EndHorizontal();
            BindableObjectHelper.BindableObjectField(temp, 0);
        }