public override void OnInspectorGUI() { serializedObject.Update(); ViewRegistry registry = (ViewRegistry)target; Setup(registry); if (_types.Count < 1) { EditorGUILayout.LabelField( "No IView interfaces found." ); return; } foreach (BindingView view in _editorViews) { DrawBinding(view); } List <TypeBinding> bindings = registry.Bindings; if (GUILayout.Button("+")) { AddNewBinding(bindings); } if (_bindingToRemove != null) { int bindingIndex = _editorViews.IndexOf(_bindingToRemove); BindingView view = _editorViews[bindingIndex]; bindings.Remove(view.Binding); _editorViews.RemoveAt(bindingIndex); _bindingToRemove = null; } serializedObject.ApplyModifiedProperties(); // TODO: Only set dirty when data is changed. EditorUtility.SetDirty(registry); }
private void Setup(ViewRegistry view) { if (_view == view) { return; } foreach (TypeBinding binding in view.Bindings) { int typeIndex = GetIndexFromQualifiedTypeName(binding.TypeName); Type bindingType = GetTypeFromIndex(typeIndex); var bindingView = new BindingView() { Binding = binding, TypeIndex = typeIndex }; TagTypeData tagData = null; if (bindingType != null) { _tagTypes.TryGetValue(bindingType, out tagData); } foreach (BindingTarget target in binding.Targets) { int tagIndex = 0; if (tagData != null) { tagIndex = tagData.Values.IndexOf(target.Tag); } var targetView = new TargetView() { Target = target, TagIndex = tagIndex }; bindingView.TargetViews.Add(targetView); } _editorViews.Add(bindingView); } _view = view; }
public void Setup(ViewRegistry registry, Core.ILogger logger) { if (logger == null) { logger = new NullLogger(); } _logger = logger; foreach (TypeBinding bindingData in registry.Bindings) { Type type = Type.GetType(bindingData.TypeName); if (type == null) { _logger.LogError(string.Format( "Could not get type for qualified name '{0}'", bindingData.TypeName )); continue; } var binding = new Binding(); binding.Targets.AddRange(bindingData.Targets); _bindings.Add(type, binding); } }
public ViewManagerSystem(ViewRegistry registry) { _registry = registry; }