void _drawNonUnityValue <T>(ValueS valueS, Func <ValueS, object> drawAction) { if (!typeof(T).IsAssignableFrom(valueS.ValueType)) { return; } var value = drawAction(valueS); if (GUI.changed) { valueS.SetValue(value); _save(); } }
public void SetBlackboardVariable(Dictionary <string, object> variable) { if (variable == null) { Debug.LogWarning("variable map is null"); return; } _varMap.Clear(); foreach (var valuePair in variable) { var value = new ValueS(); value.SetValue(valuePair.Value); _varMap.Add(valuePair.Key, value); } _setBlackboardValue(); }
private void _drawValueTypeSelect(ValueS value) { if (GUILayout.Button(new GUIContent("T", "Select Type"))) { _simpleTypeSelect.OnChangeTypeSelect = type => { value.ValueType = type; _save(); _simpleTypeSelect.editorWindow.Close(); }; var size = 250; PopupWindow.Show( new Rect(new Vector2(Event.current.mousePosition.x - size / 2, -(_rect.height - size - (Event.current.mousePosition.y + 60))) , new Vector2(size + 150, size)), _simpleTypeSelect); } }
private void _drawValue(ValueS valueS) { //todo draw Value if (valueS.IsUnity) { Object obj; EditorGUI.BeginChangeCheck(); { obj = EditorGUILayout.ObjectField(valueS.UValue, valueS.ValueType, false); } if (EditorGUI.EndChangeCheck()) { valueS.SetValue(obj); _save(); } } else { //todo non Unity Type var value = valueS.GetValue(); if (value == null) { valueS.SetValue(Activator.CreateInstance(valueS.ValueType)); _save(); } _drawNonUnityValue <int>(valueS, x => EditorGUILayout.DelayedIntField((int)x.GetValue())); _drawNonUnityValue <float>(valueS, x => EditorGUILayout.DelayedFloatField((float)x.GetValue())); _drawNonUnityValue <double>(valueS, x => EditorGUILayout.DelayedDoubleField((double)x.GetValue())); _drawNonUnityValue <long>(valueS, x => EditorGUILayout.LongField((long)x.GetValue())); _drawNonUnityValue <string>(valueS, x => EditorGUILayout.DelayedTextField((string)x.GetValue())); _drawNonUnityValue <Vector2>(valueS, x => EditorGUILayout.Vector2Field("", (Vector2)x.GetValue())); _drawNonUnityValue <Vector2Int>(valueS, x => EditorGUILayout.Vector2IntField("", (Vector2Int)x.GetValue())); _drawNonUnityValue <Vector3>(valueS, x => EditorGUILayout.Vector3Field("", (Vector3)x.GetValue())); _drawNonUnityValue <Vector3Int>(valueS, x => EditorGUILayout.Vector3IntField("", (Vector3Int)x.GetValue())); _drawNonUnityValue <Vector4>(valueS, x => EditorGUILayout.Vector4Field("", (Vector4)x.GetValue())); _drawNonUnityValue <Color>(valueS, x => EditorGUILayout.ColorField((Color)x.GetValue())); _drawNonUnityValue <AnimationCurve>(valueS, x => EditorGUILayout.CurveField((AnimationCurve)x.GetValue())); _drawNonUnityValue <Bounds>(valueS, x => EditorGUILayout.BoundsField((Bounds)x.GetValue())); _drawNonUnityValue <BoundsInt>(valueS, x => EditorGUILayout.BoundsIntField((BoundsInt)x.GetValue())); _drawNonUnityValue <Rect>(valueS, x => EditorGUILayout.RectField((Rect)x.GetValue())); _drawNonUnityValue <RectInt>(valueS, x => EditorGUILayout.RectIntField((RectInt)x.GetValue())); _drawNonUnityValue <Enum>(valueS, x => EditorGUILayout.EnumFlagsField((Enum)x.GetValue())); _drawNonUnityValue <Gradient>(valueS, x => EditorGUILayout.GradientField((Gradient)x.GetValue())); if (GUILayout.Button("Edit Value")) { var size = 250; _ValueEditPopup.ValueS = valueS; PopupWindow.Show( new Rect(new Vector2(Event.current.mousePosition.x - size / 2, -(_rect.height - size - (Event.current.mousePosition.y + 60))) , new Vector2(size, size)), _ValueEditPopup); } } }