Esempio n. 1
0
        public static void DataBindingField(GUIContent label, DataBinding bind, UnityEngine.Object bindOwner, bool isForSetter, Type[] limitTypes = null)
        {
            DataProviderEd.LoadDefinedProviders();
            int selectedIndex = (!((UnityEngine.Object)bind.dataprovider == (UnityEngine.Object)null)) ? (isForSetter ? DataProviderEd.setterProviders.IndexOf(bind.dataprovider) : DataProviderEd.getterProviders.IndexOf(bind.dataprovider)) : 0;

            EditorGUILayout.BeginHorizontal();
            if ((UnityEngine.Object)bind.dataprovider != (UnityEngine.Object)null && string.IsNullOrEmpty(bind.dataprovider.ident))
            {
                if (label == null)
                {
                    if (GUILayout.Button(DataProviderEd.GetDataBindingLabel(bind.dataprovider), plyEdGUI.Styles.MiniButtonLeft))
                    {
                        DataBindingWindow.Show_DataBindingWindow(bind, bindOwner, isForSetter, limitTypes);
                    }
                }
                else if (plyEdGUI.LabelButton(label, DataProviderEd.GetDataBindingLabel(bind.dataprovider), plyEdGUI.Styles.MiniButtonLeft))
                {
                    DataBindingWindow.Show_DataBindingWindow(bind, bindOwner, isForSetter, limitTypes);
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                selectedIndex = ((label != null) ? EditorGUILayout.Popup(label, selectedIndex, isForSetter ? DataProviderEd.setterProviderLabels : DataProviderEd.getterProviderLabels, plyEdGUI.Styles.MiniButtonLeft) : EditorGUILayout.Popup(selectedIndex, isForSetter ? DataProviderEd.setterProviderLabels : DataProviderEd.getterProviderLabels, plyEdGUI.Styles.MiniButtonLeft));
                if (EditorGUI.EndChangeCheck())
                {
                    bind.dataprovider = (isForSetter ? DataProviderEd.setterProviders[selectedIndex] : DataProviderEd.getterProviders[selectedIndex]);
                }
            }
            if (GUILayout.Button(DataProviderEd.GC_EdButton, plyEdGUI.Styles.MiniButtonRight, GUILayout.Width(25f)))
            {
                DataBindingWindow.Show_DataBindingWindow(bind, bindOwner, isForSetter, limitTypes);
            }
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 2
0
        public static void Show_DataBindingWindow(GUIContent label, DataBinding databinding, UnityEngine.Object owningObject)
        {
            DataBindingWindow window = EditorWindow.GetWindow <DataBindingWindow>(true, "Data Binding", true);

            window.label        = label;
            window.target       = databinding;
            window.databinding  = databinding.Copy();
            window.owningObject = owningObject;
            window.Init();
            window.minSize = new Vector2(270f, 150f);
            window.ShowUtility();
        }
Esempio n. 3
0
        public static void Show_DataBindingWindow(DataBinding bind, UnityEngine.Object bindOwner, bool isForSetter, Type[] limitTypes)
        {
            DataBindingWindow dataBindingWindow = ScriptableObject.CreateInstance <DataBindingWindow>();

            dataBindingWindow.titleContent = new GUIContent("Data Binding");
            dataBindingWindow.bind         = bind;
            dataBindingWindow.bindOwner    = bindOwner;
            dataBindingWindow.isForSetter  = isForSetter;
            dataBindingWindow.limitTypes   = limitTypes;
            dataBindingWindow.Init();
            dataBindingWindow.minSize = new Vector2(300f, 200f);
            dataBindingWindow.ShowUtility();
        }
Esempio n. 4
0
        public override void DrawEditor(Rect rect, DataProvider target)
        {
            ComparisonCheck comparisonCheck = target as ComparisonCheck;

            if (ComparisonCheckEd.GC_Operator == null)
            {
                ComparisonCheckEd.GC_Operator = new GUIContent[ComparisonCheckEd.S_ComparisonOpt.Length];
                for (int i = 0; i < ComparisonCheckEd.GC_Operator.Length; i++)
                {
                    ComparisonCheckEd.GC_Operator[i] = new GUIContent(ComparisonCheckEd.S_ComparisonOpt[i]);
                }
            }
            Rect position  = rect;
            Rect position2 = rect;

            position2.width = 25f;
            position.width  = (float)((position.width - position2.width) / 2.0);
            position2.x    += position.width;
            if (GUI.Button(position, base.GetDataBindingLabel(comparisonCheck.param1), EditorStyles.miniButtonLeft))
            {
                DataBindingWindow.Show_DataBindingWindow(ComparisonCheckEd.GC_Param1, comparisonCheck.param1, comparisonCheck);
            }
            if (GUI.Button(position2, ComparisonCheckEd.GC_Operator[(uint)comparisonCheck.comparisonOpt], EditorStyles.miniButtonMid))
            {
                ComparisonCheckEd.optMenu = new GenericMenu();
                for (int j = 0; j < ComparisonCheckEd.GC_Operator.Length; j++)
                {
                    ComparisonCheckEd.optMenu.AddItem(ComparisonCheckEd.GC_Operator[j], false, this.OnOptChosen, new Data
                    {
                        obj = comparisonCheck,
                        idx = j
                    });
                }
                ComparisonCheckEd.optMenu.DropDown(position2);
            }
            position.x = position.x + position.width + position2.width;
            if (GUI.Button(position, base.GetDataBindingLabel(comparisonCheck.param2), EditorStyles.miniButtonRight))
            {
                DataBindingWindow.Show_DataBindingWindow(ComparisonCheckEd.GC_Param2, comparisonCheck.param2, comparisonCheck);
            }
        }