private void DoConstant() { EditorGUI.BeginChangeCheck(); this.varTypeIdx = EditorGUILayout.Popup(DataBindingWindow.GC_ValueType, this.varTypeIdx, DataBindingWindow.varEdLabels); if (EditorGUI.EndChangeCheck()) { this.currVarEd = DataBindingWindow.varEditors[this.varTypeIdx]; Type _ = this.currVarEd.nfo.TargetType; this.databinding.constant = plyVar.Create(this.currVarEd.nfo.TargetType); this.databinding.constant.name = "constant"; } if (this.currVarEd != null && this.databinding.constant != null) { Rect rect = GUILayoutUtility.GetRect(0f, EditorGUIUtility.singleLineHeight, GUILayout.ExpandWidth(true)); rect.x = (float)(rect.x + EditorGUIUtility.labelWidth + 5.0); rect.width -= (float)(EditorGUIUtility.labelWidth + 15.0); this.currVarEd.DrawEditor(rect, false, this.databinding.constant, this.databinding.constant, 0); } }
private void InitConstant() { if (DataBindingWindow.varEdLabels == null || DataBindingWindow.varEditors == null) { DataBindingWindow.varEditors = new List <plyVarEd>(); plyVariablesEditor.LoadVarEds(); foreach (plyVarEd value in plyVariablesEditor.editors.Values) { if (!((plyVarEdAttribute)value.nfo).UsesAdvancedEditor) { DataBindingWindow.varEditors.Add(value); } } DataBindingWindow.varEdLabels = new GUIContent[DataBindingWindow.varEditors.Count]; for (int i = 0; i < DataBindingWindow.varEditors.Count; i++) { DataBindingWindow.varEdLabels[i] = new GUIContent(((plyVarEdAttribute)DataBindingWindow.varEditors[i].nfo).VarTypeName); } } this.varTypeIdx = -1; if (this.databinding.dataContext == DataBinding.DataContext.Constant && this.databinding.constant != null) { Type type = this.databinding.constant.ValueHandler.GetType(); for (int j = 0; j < DataBindingWindow.varEditors.Count; j++) { plyVarEdAttribute plyVarEdAttribute = (plyVarEdAttribute)DataBindingWindow.varEditors[j].nfo; if (type == plyVarEdAttribute.TargetType) { this.currVarEd = DataBindingWindow.varEditors[j]; this.varTypeIdx = j; break; } } } if (this.varTypeIdx == -1) { this.varTypeIdx = 0; this.currVarEd = DataBindingWindow.varEditors[0]; this.databinding.constant = plyVar.Create(this.currVarEd.nfo.TargetType); this.databinding.constant.name = "constant"; } }
private void Init(ConstantValueProvider Target) { if (ConstantValueProviderEd.varEdLabels == null || ConstantValueProviderEd.varEditors == null) { ConstantValueProviderEd.varEditors = new List <plyVarEd>(); plyVariablesEditor.LoadVarEds(); foreach (plyVarEd value in plyVariablesEditor.editors.Values) { if (!((plyVarEdAttribute)value.nfo).UsesAdvancedEditor) { ConstantValueProviderEd.varEditors.Add(value); } } ConstantValueProviderEd.varEdLabels = new GUIContent[ConstantValueProviderEd.varEditors.Count]; for (int i = 0; i < ConstantValueProviderEd.varEditors.Count; i++) { ConstantValueProviderEd.varEdLabels[i] = new GUIContent(((plyVarEdAttribute)ConstantValueProviderEd.varEditors[i].nfo).VarTypeName); } } if (this.currVarEd == null) { this.selectedEdType = Target.constant.ValueHandler.GetType(); for (int j = 0; j < ConstantValueProviderEd.varEditors.Count; j++) { plyVarEdAttribute plyVarEdAttribute = (plyVarEdAttribute)ConstantValueProviderEd.varEditors[j].nfo; if (this.selectedEdType == plyVarEdAttribute.TargetType) { this.currVarEd = ConstantValueProviderEd.varEditors[j]; this.varTypeIdx = j; break; } } } if (this.varTypeIdx < 0) { this.varTypeIdx = 0; this.currVarEd = ConstantValueProviderEd.varEditors[0]; Target.constant = plyVar.Create(this.currVarEd.nfo.TargetType); Target.constant.name = "constant"; } }
protected override void Draw(Rect rect, DataProvider target, bool isSetter) { ConstantValueProvider constantValueProvider = (ConstantValueProvider)target; this.Init(constantValueProvider); rect.height = EditorGUIUtility.singleLineHeight; EditorGUI.BeginChangeCheck(); this.varTypeIdx = EditorGUI.Popup(rect, ConstantValueProviderEd.GC_ValueType, this.varTypeIdx, ConstantValueProviderEd.varEdLabels); if (EditorGUI.EndChangeCheck()) { this.currVarEd = ConstantValueProviderEd.varEditors[this.varTypeIdx]; constantValueProvider.constant = plyVar.Create(this.currVarEd.nfo.TargetType); constantValueProvider.constant.name = "constant"; } if (this.currVarEd != null && constantValueProvider.constant != null) { rect.y += (float)(EditorGUIUtility.singleLineHeight + 2.0); rect.x += EditorGUIUtility.labelWidth; rect.width -= EditorGUIUtility.labelWidth; this.currVarEd.DrawEditor(rect, false, constantValueProvider.constant, constantValueProvider.constant, 0); } }