private void Save(string filePath) { var views = _worldObjectContainer.GetComponentsInChildren <IWorldObjectView>(); var models = new IWorldObjectModel[views.Length]; for (int i = 0; i < views.Length; i++) { models[i] = views[i].Model; } IOProcessor.Save(filePath, models); }
public void HandleWorldObjectSelected(object sender, WorldObjectSelectedEventArgs args) { // Deregister from previous model's update action if (_model != null) { _model.OnModelUpdate -= UpdateView; } _model = args.objectModel; positionGizmo.Model = _model; rotationGizmo.Model = _model; // Register for this new model's update action. if (_model != null) { _model.OnModelUpdate += UpdateView; UpdateView(); } // If the model is null, means no object is selected. turn off. this.gameObject.SetActive(_model != null); }
public void WorldObjectClicked(IWorldObjectView worldObject, MouseClickType clickType) { if (_selectedView != null) { _selectedView.SetSelected(false); _selectedView = null; } IWorldObjectModel model = null; if (worldObject != null) { model = worldObject.Model; _selectedView = worldObject; _selectedView.SetSelected(true); } if (WorldObjectSelectedEventHandler != null) { WorldObjectSelectedEventHandler(this, new WorldObjectSelectedEventArgs(model, clickType)); } }
public WorldObjectSelectedEventArgs(IWorldObjectModel objectModel, MouseClickType clickType) { this.objectModel = objectModel; this.clickType = clickType; }