public static DataProvider CreateDataprovider(Type t, string ident, bool isSetter) { plyEdUtil.CheckPath(BloxEdGlobal.ProvidersPath); string str = plyEdUtil.GenerateUniqueFileGUID("", BloxEdGlobal.ProvidersPath, ".asset"); DataProvider dataProvider = (DataProvider)plyEdUtil.LoadOrCreateAsset(t, BloxEdGlobal.ProvidersPath + str + ".asset", false); dataProvider.ident = ident; dataProvider.isSetter = isSetter; dataProvider.OnCreated(); EditorUtility.SetDirty(dataProvider); AssetDatabase.SaveAssets(); if (!string.IsNullOrEmpty(ident)) { DataProviderEd.LoadDefinedProviders(); if (isSetter) { DataProviderEd.setterProviders.Add(dataProvider); } else { DataProviderEd.getterProviders.Add(dataProvider); } DataProviderEd.UpdateProviderLabels(); } return(dataProvider); }
public static void LoadDefinedProviders() { if (DataProviderEd.getterProviders != null && DataProviderEd.setterProviders != null) { return; } DataProviderEd.getterProviders = new List <DataProvider>(); DataProviderEd.setterProviders = new List <DataProvider>(); plyEdUtil.CheckPath(BloxEdGlobal.ProvidersPath); List <DataProvider> list = plyEdUtil.LoadAssets <DataProvider>(BloxEdGlobal.ProvidersPath); for (int i = 0; i < list.Count; i++) { if (!string.IsNullOrEmpty(list[i].ident)) { if (list[i].isSetter) { DataProviderEd.setterProviders.Add(list[i]); } else { DataProviderEd.getterProviders.Add(list[i]); } } } DataProviderEd.getterProviders.Insert(0, null); DataProviderEd.setterProviders.Insert(0, null); DataProviderEd.UpdateProviderLabels(); }
private void AddDataProvider(plyTextInputWiz wiz) { string text = wiz.text; wiz.Close(); if (string.IsNullOrEmpty(text)) { this.isNewlyCreated = true; this.bind.dataprovider = DataProviderEd.CreateDataprovider <plyVarDataProvider>("", this.isForSetter); plyEdUtil.SetDirty(this.bindOwner); this.CreateProviderEd(); } else if (this.NameIsUniqueInDefined(text)) { this.isNewlyCreated = true; this.bind.dataprovider = DataProviderEd.CreateDataprovider <plyVarDataProvider>(text, this.isForSetter); plyEdUtil.SetDirty(this.bindOwner); this.CreateProviderEd(); } else { EditorUtility.DisplayDialog("Create", "The name must be unique.", "OK"); } base.Repaint(); }
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(); }
protected override void Draw(Rect rect, DataProvider target, bool isSetter) { MathsDataProvider mathsDataProvider = target as MathsDataProvider; if (MathsDataProviderEd.GC_Operator == null) { MathsDataProviderEd.GC_Operator = new GUIContent[MathsDataProviderEd.S_ComparisonOpt.Length]; for (int i = 0; i < MathsDataProviderEd.GC_Operator.Length; i++) { MathsDataProviderEd.GC_Operator[i] = new GUIContent(MathsDataProviderEd.S_ComparisonOpt[i]); } } Rect r = rect; Rect position = rect; position.width = 20f; r.width = (float)((r.width - position.width) / 2.0); position.x += r.width; DataProviderEd.DataBindingField(r, null, mathsDataProvider.param1, mathsDataProvider, false, null); if (GUI.Button(position, MathsDataProviderEd.GC_Operator[(int)mathsDataProvider.opt], plyEdGUI.Styles.MiniButton_LeftText)) { MathsDataProviderEd.optMenu = new GenericMenu(); for (int j = 0; j < MathsDataProviderEd.GC_Operator.Length; j++) { MathsDataProviderEd.optMenu.AddItem(MathsDataProviderEd.GC_Operator[j], false, this.OnOptChosen, new Data { obj = mathsDataProvider, idx = j }); } MathsDataProviderEd.optMenu.DropDown(position); } r.x = r.x + r.width + position.width; DataProviderEd.DataBindingField(r, null, mathsDataProvider.param2, mathsDataProvider, false, null); }
public static SimpleParamInfo[] GetBindParams(DataBinding bind) { if ((UnityEngine.Object)bind.dataprovider != (UnityEngine.Object)null) { DataProviderEd dataProviderEd = DataProviderEd.editors[bind.dataprovider.GetType()]; if (dataProviderEd != null) { return(dataProviderEd.GetSetterParams(bind.dataprovider)); } } return(new SimpleParamInfo[0]); }
protected override void Draw(Rect rect, DataProvider target, bool isSetter) { CurveDataMapProvider curveDataMapProvider = target as CurveDataMapProvider; CurveDataMapProviderEd.GC_Label.text = DataProviderEd.GetDataBindingLabel(curveDataMapProvider.param1.dataprovider); rect.height = EditorGUIUtility.singleLineHeight; DataProviderEd.DataBindingField(rect, CurveDataMapProviderEd.GC_Param1, curveDataMapProvider.param1, curveDataMapProvider, false, null); rect.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); curveDataMapProvider.curve = EditorGUI.CurveField(rect, CurveDataMapProviderEd.GC_Curve, curveDataMapProvider.curve); rect.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); curveDataMapProvider.roundingOpt = (RoundingOption)EditorGUI.EnumPopup(rect, CurveDataMapProviderEd.GC_Rounding, (Enum)(object)curveDataMapProvider.roundingOpt); }
protected override void Draw(Rect rect, DataProvider target, bool isSetter) { GraphMappedValuesProvider graphMappedValuesProvider = target as GraphMappedValuesProvider; GraphMappedValuesProviderEd.GC_Label.text = DataProviderEd.GetDataBindingLabel(graphMappedValuesProvider.param1.dataprovider); rect.height = EditorGUIUtility.singleLineHeight; DataProviderEd.DataBindingField(rect, GraphMappedValuesProviderEd.GC_Param1, graphMappedValuesProvider.param1, graphMappedValuesProvider, false, null); rect.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); graphMappedValuesProvider.yIsInput = EditorGUI.Toggle(rect, GraphMappedValuesProviderEd.GC_InputY, graphMappedValuesProvider.yIsInput); rect.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); graphMappedValuesProvider.curve = plyEdGUI.GraphMappedValuesField(rect, GraphMappedValuesProviderEd.GC_Curve, graphMappedValuesProvider.curve); }
public static void UpdateProviderLabels() { DataProviderEd.LoadDefinedProviders(); DataProviderEd.getterProviders.Sort(delegate(DataProvider a, DataProvider b) { if (!((UnityEngine.Object)a == (UnityEngine.Object)null)) { if (!((UnityEngine.Object)b == (UnityEngine.Object)null)) { return(a.ident.CompareTo(b.ident)); } return(1); } return(-1); }); DataProviderEd.setterProviders.Sort(delegate(DataProvider a, DataProvider b) { if (!((UnityEngine.Object)a == (UnityEngine.Object)null)) { if (!((UnityEngine.Object)b == (UnityEngine.Object)null)) { return(a.ident.CompareTo(b.ident)); } return(1); } return(-1); }); DataProviderEd.getterProviderLabels = new GUIContent[DataProviderEd.getterProviders.Count]; DataProviderEd.setterProviderLabels = new GUIContent[DataProviderEd.setterProviders.Count]; for (int i = 0; i < DataProviderEd.getterProviders.Count; i++) { if ((UnityEngine.Object)DataProviderEd.getterProviders[i] == (UnityEngine.Object)null) { DataProviderEd.getterProviderLabels[i] = new GUIContent("None"); } else { DataProviderEd.getterProviderLabels[i] = new GUIContent(DataProviderEd.getterProviders[i].ident); } } for (int j = 0; j < DataProviderEd.setterProviders.Count; j++) { if ((UnityEngine.Object)DataProviderEd.setterProviders[j] == (UnityEngine.Object)null) { DataProviderEd.setterProviderLabels[j] = new GUIContent("None"); } else { DataProviderEd.setterProviderLabels[j] = new GUIContent(DataProviderEd.setterProviders[j].ident); } } }
public static string GetDataBindingLabel(DataProvider p) { if ((UnityEngine.Object)p == (UnityEngine.Object)null) { return("None"); } if (!string.IsNullOrEmpty(p.ident)) { return(p.ident); } DataProviderEd dataProviderEd = DataProviderEd.editors[p.GetType()]; if (dataProviderEd != null) { return(dataProviderEd.Label(p)); } return("-unknown-dataprovider-"); }
private bool NameIsUniqueInDefined(string s) { DataProviderEd.LoadDefinedProviders(); for (int i = 0; i < DataProviderEd.getterProviders.Count; i++) { if (!((UnityEngine.Object)DataProviderEd.getterProviders[i] == (UnityEngine.Object)null) && s.Equals(DataProviderEd.getterProviders[i].ident)) { return(false); } } for (int j = 0; j < DataProviderEd.setterProviders.Count; j++) { if (!((UnityEngine.Object)DataProviderEd.setterProviders[j] == (UnityEngine.Object)null) && s.Equals(DataProviderEd.setterProviders[j].ident)) { return(false); } } return(true); }
private void DoDataProvider() { if (this.providerLabels == null) { base.Close(); GUIUtility.ExitGUI(); } else { if (this.isNewlyCreated) { EditorGUI.BeginChangeCheck(); this.providerIdx = EditorGUILayout.Popup(DataBindingWindow.GC_Space, this.providerIdx, this.providerLabels); if (EditorGUI.EndChangeCheck()) { string ident = this.bind.dataprovider.ident; DataProviderEd.DestroyDataprovider(this.bind.dataprovider); this.providerEd = DataProviderEd.factory.CreateEditor(this.providerLabels[this.providerIdx].text); this.bind.dataprovider = DataProviderEd.CreateDataprovider(this.providerEd.nfo.TargetType, ident, this.isForSetter); plyEdUtil.SetDirty(this.bindOwner); } } else { GUI.enabled = false; EditorGUILayout.Popup(DataBindingWindow.GC_Space, this.providerIdx, this.providerLabels); GUI.enabled = true; } DataBindingWindow.GC_Text.text = BloxEd.PrettyTypeName(this.bind.dataprovider.DataType(), !this.isForSetter); EditorGUILayout.LabelField(DataBindingWindow.GC_Space, DataBindingWindow.GC_Text); if (this.providerEd != null) { Rect rect = GUILayoutUtility.GetRect(0f, (float)(this.providerEd.EditorHeight(this.bind.dataprovider, this.isForSetter) + 10.0), GUILayout.ExpandWidth(true)); rect.x += 5f; rect.width -= 10f; rect.y += 10f; rect.height -= 10f; this.providerEd.DrawEditor(rect, this.bind.dataprovider, this.isForSetter); base.Repaint(); } } }
private void RenameDataProvider(plyTextInputWiz wiz) { string text = wiz.text; wiz.Close(); if (!string.IsNullOrEmpty(text) && !text.Equals(this.bind.dataprovider.ident)) { if (this.NameIsUniqueInDefined(text)) { this.bind.dataprovider.ident = text; plyEdUtil.SetDirty(this.bind.dataprovider); DataProviderEd.UpdateProviderLabels(); } else { EditorUtility.DisplayDialog("Rename", "The name must be unique.", "OK"); } base.Repaint(); } }
public static DataBindingValueSource DataBindingValueSourceField(Rect rect, GUIContent label, DataBindingValueSource val, GUIContent bindWinLabel, UnityEngine.Object ownerObj) { if (val == null) { val = new DataBindingValueSource(); GUI.changed = true; } Rect rect2 = rect; if (label != null) { rect2.width = EditorGUIUtility.labelWidth; GUI.Label(rect2, label); rect2.x += EditorGUIUtility.labelWidth; rect2.width = rect.width - EditorGUIUtility.labelWidth; } float num = (float)((rect2.width - 2.0) / 2.0); rect2.width = num; val.source = (DataBindingValueSource.Source)EditorGUI.EnumPopup(rect2, (Enum)(object)val.source); rect2.x = (float)(rect2.x + num + 2.0); if (val.source == DataBindingValueSource.Source.Blackboard) { if (val.databind != null) { DataProviderEd.DestroyDataprovider(val.databind.dataprovider); val.databind = null; } val.blackboardValueName = EditorGUI.TextArea(rect2, val.blackboardValueName); } else if (val.source == DataBindingValueSource.Source.DataProvider) { if (val.databind == null) { val.databind = new DataBinding(); } DataProviderEd.DataBindingField(rect2, null, val.databind, ownerObj, false, null); } return(val); }
protected void OnGUI() { EditorGUIUtility.labelWidth = 85f; EditorGUILayout.BeginHorizontal(); GUILayout.Label(DataBindingWindow.GC_Dataprovider, GUILayout.Width((float)(EditorGUIUtility.labelWidth - 4.0))); GUI.enabled = false; EditorGUILayout.TextField(((UnityEngine.Object) this.bind.dataprovider == (UnityEngine.Object)null) ? "" : this.bind.dataprovider.ident, plyEdGUI.Styles.TextField_NoRightMargin); GUI.enabled = ((UnityEngine.Object) this.bind.dataprovider != (UnityEngine.Object)null); if (GUILayout.Button(DataBindingWindow.GC_Rename, plyEdGUI.Styles.MiniButtonMid, GUILayout.Width(25f))) { plyTextInputWiz.ShowWiz("Rename Data Provider", "Enter a unique name", this.bind.dataprovider.ident, this.RenameDataProvider, null, 250f); } if (GUILayout.Button(DataBindingWindow.GC_Delete, plyEdGUI.Styles.MiniButtonMid, GUILayout.Width(25f)) && EditorUtility.DisplayDialog("Delete Data Provider", "Deleting the data provider can't be undone. Continue?", "Yes", "Cancel")) { DataProviderEd.DestroyDataprovider(this.bind.dataprovider); this.bind.dataprovider = null; this.providerEd = null; this.providerIdx = -1; } GUI.enabled = true; if (GUILayout.Button(DataBindingWindow.GC_CreateNew, plyEdGUI.Styles.MiniButtonRight, GUILayout.Width(80f))) { plyTextInputWiz.ShowWiz("New Data Provider", "Enter unique name or leave empty", "", this.AddDataProvider, null, 250f); } EditorGUILayout.EndHorizontal(); if ((UnityEngine.Object) this.bind.dataprovider != (UnityEngine.Object)null) { this.DoDataProvider(); } GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(plyEdGUI.Styles.BottomBar); GUILayout.FlexibleSpace(); if (GUILayout.Button("Accept", GUILayout.Width(80f))) { this.accepted = true; } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
public static void DestroyDataprovider(DataProvider p) { if (!((UnityEngine.Object)p == (UnityEngine.Object)null)) { DataProviderEd.LoadDefinedProviders(); List <DataProvider> dataProvidersForDestruction = p.GetDataProvidersForDestruction(); dataProvidersForDestruction.Add(p); for (int i = 0; i < dataProvidersForDestruction.Count; i++) { if (dataProvidersForDestruction[i].isSetter) { DataProviderEd.setterProviders.Remove(dataProvidersForDestruction[i]); } else { DataProviderEd.getterProviders.Remove(dataProvidersForDestruction[i]); } plyEdUtil.DeleteAsset(dataProvidersForDestruction[i]); } DataProviderEd.UpdateProviderLabels(); } }
private void CreateProviderEd() { this.providerIdx = 0; this.providerEd = DataProviderEd.factory.CreateEditor(this.bind.dataprovider.GetType()); if (this.providerEd != null) { int num = 0; while (true) { if (num < this.providerLabels.Length) { if (!(this.providerLabels[num].text == this.providerEd.nfo.Name)) { num++; continue; } break; } return; } this.providerIdx = num; } }
protected override void Draw(Rect rect, DataProvider target, bool isSetter) { ComparisonDataProvider comparisonDataProvider = target as ComparisonDataProvider; rect.height = EditorGUIUtility.singleLineHeight; 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 r = rect; Rect position = rect; position.width = 28f; r.width = (float)((r.width - position.width) / 2.0); position.x += r.width; DataProviderEd.DataBindingField(r, null, comparisonDataProvider.param1, comparisonDataProvider, false, null); if (GUI.Button(position, ComparisonCheckEd.GC_Operator[(int)comparisonDataProvider.comparisonOpt])) { 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 = comparisonDataProvider, idx = j }); } ComparisonCheckEd.optMenu.DropDown(position); } r.x = r.x + r.width + position.width; DataProviderEd.DataBindingField(r, null, comparisonDataProvider.param2, comparisonDataProvider, false, null); }
protected override void Draw(Rect rect, DataProvider target, bool isSetter) { MemberBindProvider memberBindProvider = (MemberBindProvider)target; rect.height = EditorGUIUtility.singleLineHeight; if (MemberBindProviderEd.loader != null) { plyEdGUI.DrawSpinner(rect, MemberBindProviderEd.GC_Loading); if (Event.current.type == EventType.Repaint) { MemberBindProviderEd.loader.DoUpdate(); } } else { this.InitCurrBindables(memberBindProvider, isSetter); EditorGUIUtility.labelWidth = 65f; Rect rect2 = rect; GUIContent label = isSetter ? MemberBindProviderEd.GC_SetMember : MemberBindProviderEd.GC_GetMember; if (memberBindProvider.member != null && memberBindProvider.member.MemberType == MemberTypes.Method) { label = MemberBindProviderEd.GC_InvokeMember; } EditorGUI.BeginChangeCheck(); this.memberBindIdx = EditorGUI.Popup(rect2, label, this.memberBindIdx, this.currBindableLabels); if (EditorGUI.EndChangeCheck()) { memberBindProvider.member = this.currBindables[this.memberBindIdx].mi; memberBindProvider.instanceMember = null; if (memberBindProvider.valSetterSources.Length != 0) { memberBindProvider.valSetterSources = new DataBindingValueSource[0]; } if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.Instance) { MemberBindProvider target2 = memberBindProvider; BloxMemberInfo member = memberBindProvider.member; this.InitSubBindables(target2, (member != null) ? member.ReflectedType : null); } } if (memberBindProvider.member == null) { if (memberBindProvider.instanceMember != null) { memberBindProvider.instanceMember = null; GUI.changed = true; } if (memberBindProvider.valSetterSources.Length != 0) { memberBindProvider.valSetterSources = new DataBindingValueSource[0]; GUI.changed = true; } } else { if (!memberBindProvider.member.IsStatic) { rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); if (memberBindProvider.sourceObjType != 0 && memberBindProvider.sourceObjType != MemberBindProvider.DataSourceOject.Owner) { rect2.width = (float)(EditorGUIUtility.labelWidth + 100.0); } EditorGUI.BeginChangeCheck(); memberBindProvider.sourceObjType = (MemberBindProvider.DataSourceOject)EditorGUI.EnumPopup(rect2, MemberBindProviderEd.GC_TargetObject, (Enum)(object)memberBindProvider.sourceObjType); if (EditorGUI.EndChangeCheck()) { memberBindProvider.sourceObjData = ""; if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.Instance) { MemberBindProvider target3 = memberBindProvider; BloxMemberInfo member2 = memberBindProvider.member; this.InitSubBindables(target3, (member2 != null) ? member2.ReflectedType : null); } } rect2.x += (float)(EditorGUIUtility.labelWidth + 102.0); rect2.width = (float)(rect.width - (EditorGUIUtility.labelWidth + 102.0)); if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.WithName || memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.WithTag) { memberBindProvider.sourceObjData = EditorGUI.TextField(rect2, memberBindProvider.sourceObjData); } else if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.OfType) { EditorGUI.LabelField(rect2, BloxEd.PrettyTypeName(memberBindProvider.member.ReflectedType, true)); } else if (memberBindProvider.sourceObjType == MemberBindProvider.DataSourceOject.Instance) { EditorGUI.BeginChangeCheck(); this.subBindIdx = EditorGUI.Popup(rect2, this.subBindIdx, this.subBindableLabels); if (EditorGUI.EndChangeCheck()) { memberBindProvider.instanceMember = this.subBindables[this.subBindIdx].mi; } } } rect2.x = rect.x; rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); rect2.width = rect.width; if (memberBindProvider.member.MemberType == MemberTypes.Method) { ParameterInfo[] parameters = memberBindProvider.member.GetParameters(); if (memberBindProvider.valSetterSources.Length != parameters.Length) { GUI.changed = true; memberBindProvider.valSetterSources = new DataBindingValueSource[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { memberBindProvider.valSetterSources[i] = new DataBindingValueSource(); } } if (memberBindProvider.valSetterSources.Length != 0) { GUI.Label(rect2, MemberBindProviderEd.GC_With); for (int j = 0; j < memberBindProvider.valSetterSources.Length; j++) { MemberBindProviderEd.GC_Param.text = parameters[j].Name + "="; rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); memberBindProvider.valSetterSources[j] = DataProviderEd.DataBindingValueSourceField(rect2, MemberBindProviderEd.GC_Param, memberBindProvider.valSetterSources[j], MemberBindProviderEd.GC_ToValBindWin, memberBindProvider); } } } else if (isSetter) { if (memberBindProvider.valSetterSources.Length != 1) { GUI.changed = true; memberBindProvider.valSetterSources = new DataBindingValueSource[1] { new DataBindingValueSource() }; } memberBindProvider.valSetterSources[0] = DataProviderEd.DataBindingValueSourceField(rect2, MemberBindProviderEd.GC_ToVal, memberBindProvider.valSetterSources[0], MemberBindProviderEd.GC_ToValBindWin, memberBindProvider); } } } }
public static T CreateDataprovider <T>(string ident, bool isSetter) where T : DataProvider { return((T)DataProviderEd.CreateDataprovider(typeof(T), ident, isSetter)); }
protected override void Draw(Rect rect, DataProvider target, bool isSetter) { TriggerEventDataProvider triggerEventDataProvider = target as TriggerEventDataProvider; EditorGUIUtility.labelWidth = 110f; rect.height = EditorGUIUtility.singleLineHeight; Rect rect2 = rect; float num = 0f; rect2.width = EditorGUIUtility.labelWidth; GUI.Label(rect2, TriggerEventProviderEd.GC_VarHead); rect2.x += EditorGUIUtility.labelWidth; rect2.width = (num = (float)((rect.width - (rect2.width + 6.0)) / 2.0)); triggerEventDataProvider.varName = EditorGUI.TextField(rect2, triggerEventDataProvider.varName); Blox blox = null; if (!string.IsNullOrEmpty(triggerEventDataProvider.bloxIdent)) { blox = BloxEd.GetBloxDef(triggerEventDataProvider.bloxIdent); if ((UnityEngine.Object)blox == (UnityEngine.Object)null) { triggerEventDataProvider.bloxIdent = ""; } else { TriggerEventProviderEd.GC_BloxName.text = blox.screenName; } } TriggerEventProviderEd.GC_BloxName.text = (((UnityEngine.Object)blox == (UnityEngine.Object)null) ? "-select-" : blox.screenName); rect2.x += (float)(rect2.width + 3.0); if (GUI.Button(rect2, TriggerEventProviderEd.GC_BloxName)) { BloxListPopup.Show_BloxListPopup(null, this.OnBloxSelected, new object[1] { triggerEventDataProvider }); } rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); rect2.x = rect.x; rect2.width = EditorGUIUtility.labelWidth; GUI.Label(rect2, TriggerEventProviderEd.GC_ObjHead); rect2.x += EditorGUIUtility.labelWidth; rect2.width = num; triggerEventDataProvider.sourceObjType = (TriggerEventDataProvider.DataSourceOject)EditorGUI.EnumPopup(rect2, (Enum)(object)triggerEventDataProvider.sourceObjType); if (triggerEventDataProvider.sourceObjType != TriggerEventDataProvider.DataSourceOject.Owner) { rect2.x += (float)(rect2.width + 3.0); triggerEventDataProvider.objNameOrTag = plyEdGUI.InlineLabelTextField(rect2, (triggerEventDataProvider.sourceObjType == TriggerEventDataProvider.DataSourceOject.WithName) ? TriggerEventProviderEd.GC_ObjName : TriggerEventProviderEd.GC_TagName, triggerEventDataProvider.objNameOrTag); } rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); rect2.x = rect.x; rect2.width = EditorGUIUtility.labelWidth; GUI.Label(rect2, TriggerEventProviderEd.GC_EventHead); rect2.x += EditorGUIUtility.labelWidth; rect2.width = rect.width - EditorGUIUtility.labelWidth; triggerEventDataProvider.triggerBloxEvent = EditorGUI.TextField(rect2, triggerEventDataProvider.triggerBloxEvent); rect2.x = rect.x; rect2.width = rect.width; for (int i = 0; i < triggerEventDataProvider.valSetterSources.Length; i++) { rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); TriggerEventProviderEd.GC_Param.text = string.Format("with param{0} = ", i); triggerEventDataProvider.valSetterSources[i] = DataProviderEd.DataBindingValueSourceField(rect2, TriggerEventProviderEd.GC_Param, triggerEventDataProvider.valSetterSources[i], TriggerEventProviderEd.GC_ToValBindWin, triggerEventDataProvider); } rect2.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); rect2.x = (float)(rect.xMax - 103.0); rect2.width = 50f; GUI.Label(rect2, TriggerEventProviderEd.GC_ParamsHead); rect2.x += 53f; rect2.width = 25f; if (GUI.Button(rect2, Ico._add, plyEdGUI.Styles.MiniButtonLeft)) { DataBindingValueSource item = new DataBindingValueSource(); ArrayUtility.Add <DataBindingValueSource>(ref triggerEventDataProvider.valSetterSources, item); plyEdUtil.SetDirty(triggerEventDataProvider); } rect2.x += 25f; GUI.enabled = (triggerEventDataProvider.valSetterSources.Length != 0); if (GUI.Button(rect2, Ico._remove, plyEdGUI.Styles.MiniButtonRight)) { DataBinding databind = triggerEventDataProvider.valSetterSources[triggerEventDataProvider.valSetterSources.Length - 1].databind; DataProviderEd.DestroyDataprovider((databind != null) ? databind.dataprovider : null); ArrayUtility.RemoveAt <DataBindingValueSource>(ref triggerEventDataProvider.valSetterSources, triggerEventDataProvider.valSetterSources.Length - 1); plyEdUtil.SetDirty(triggerEventDataProvider); } GUI.enabled = true; }