コード例 #1
0
        public override void OnInspectorGUI()
        {
            VMDataBinder binder = target as VMDataBinder;

            binder.EditorBind();

            if (definerDrawer == null)
            {
                definerDrawer = new DataDefinerDrawer(binder.Source);
            }
            definerDrawer.Draw(binder.BindVM, binder.BindData, typeof(StructType));

            binder.Template = (GameObject)EditorGUILayout.ObjectField("Template:", binder.Template, typeof(GameObject), true);
            if (binder.Template == null || binder.Template.GetComponent <VMBehaviour>() == null)
            {
                GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                style.normal.textColor = Color.red;
                if (binder.Template == null)
                {
                    EditorGUILayout.LabelField("template can not be null.", style);
                }
                else
                {
                    EditorGUILayout.LabelField("template game object must have VMBehaviour.", style);
                }
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            ListDataBinder binder = target as ListDataBinder;

            binder.EditorBind();

            if (definerDrawer == null)
            {
                definerDrawer = new DataDefinerDrawer(binder.Source);
            }
            definerDrawer.Draw(binder.BindVM, binder.BindData, typeof(IList));

            binder.Template = (GameObject)EditorGUILayout.ObjectField("Template:", binder.Template, typeof(GameObject), true);
            if (binder.Template == null || binder.Template.GetComponent <ListTemplateBinder>() == null)
            {
                GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                style.normal.textColor = Color.red;
                if (binder.Template == null)
                {
                    EditorGUILayout.LabelField("template can not be null.", style);
                }
                else
                {
                    EditorGUILayout.LabelField("template game object must have ListTemplateBinder.", style);
                }
            }
            else
            {
                IData data = binder.Source.GetData(binder.BindVM);
                if (data != null && data is IListData)
                {
                    IListData list = (IListData)data;
                    if (list.Count <= 0)
                    {
                        GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                        style.normal.textColor = Color.red;
                        EditorGUILayout.LabelField("source list data must instantiate with one element at least.", style);
                    }
                    else
                    {
                        binder.Template.GetComponent <ListTemplateBinder>().ItemSource.Key = binder.Source.Key;
                    }
                }
            }

            binder.Optimize = EditorGUILayout.Toggle("Optimize:", binder.Optimize);
            if (binder.Optimize)
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField("Canvas:", binder.Canvas, typeof(Canvas), true);
                EditorGUILayout.ObjectField("ViewPort:", binder.ViewPort, typeof(RectTransform), true);
                EditorGUILayout.ObjectField("ScrollRect:", binder.ScrollRect, typeof(ScrollRect), true);
                EditorGUILayout.ObjectField("LayoutGroup:", binder.LayoutGroup, typeof(LayoutGroup), true);
                EditorGUILayout.IntField("PageRowsCount:", binder.PageRowsCount);
                EditorGUILayout.IntField("RowItemsCount:", binder.RowItemsCount);
                EditorGUILayout.IntField("StepRowsCount:", binder.StepRowsCount);
                EditorGUI.EndDisabledGroup();
            }
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            ListTemplateBinder binder = target as ListTemplateBinder;
            VMBehaviour        vm     = binder.GetComponentInParent <VMBehaviour>(true);

            if (definerDrawer == null)
            {
                definerDrawer = new DataDefinerDrawer(binder.ItemSource);
            }
            definerDrawer.Draw(vm, null, typeof(IList));

            IData     data = binder.ItemSource.GetData(vm);
            IListData list = data as IListData;

            if (list == null)
            {
                GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                style.normal.textColor = Color.red;
                EditorGUILayout.LabelField("no source list data.", style);
            }

            EditorGUILayout.LabelField("index: " + binder.Index);
        }