void scriptitem_Click(object sender, RoutedEventArgs e)
        {
            var menuitem = e.Source as MenuItem;
            EngineManagerViewModel view = (this.DataContext as EngineManagerViewModel);

            e.Handled = true;
            if (view.SelectedGameObjects.Count == 0)
            {
                return;
            }
            string scriptname = menuitem.DataContext as String;

            EditorSubsystemManaged.getInstance().QueueAction(() =>
            {
                foreach (GameObject g in view.SelectedGameObjects)
                {
                    CScript cs     = CastingHelper.CastTo <CScript>(g.RequireComponentByName("CScript"));
                    cs.scriptAsset = AssetManager.getInstance().GetAsset(scriptname);
                }
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    ComponentListViewControl.GetBindingExpression(ListView.ItemsSourceProperty).UpdateTarget();
                }));
            });
        }
Beispiel #2
0
        public EngineManagerViewModel()
        {
            instance = this;
            _model   = new Models.EngineManagerModel();

            ComponentTypes = new ObservableCollection <String>();
        }
Beispiel #3
0
        public EngineManagerViewModel()
        {
            instance = this;
            _model = new Models.EngineManagerModel();

            ComponentTypes = new ObservableCollection<String>();
        }
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (_viewModel == null && this.DataContext != null)
     {
         _viewModel = this.DataContext as EngineManagerViewModel;
     }
 }
        private void AlignViewButton_Click(object sender, RoutedEventArgs e)
        {
            EngineManagerViewModel view = (this.DataContext as EngineManagerViewModel);

            e.Handled = true;
            if (view.SelectedGameObjects.Count == 0)
            {
                return;
            }
            EditorSubsystemManaged.getInstance().QueueAction(() =>
            {
                foreach (GameObject g in view.SelectedGameObjects)
                {
                    MochaInterface.GameObject ed_cam = EditorSubsystem.getInstance().EditorCamera().gameObject;
                    g.transform.SetPosition(ed_cam.transform.position + (Vector3)ed_cam.transform.GetForwardVector() * 5);
                }
            });
        }
        private void GroundSnapButton_Click(object sender, RoutedEventArgs e)
        {
            EngineManagerViewModel view = (this.DataContext as EngineManagerViewModel);

            e.Handled = true;
            if (view.SelectedGameObjects.Count == 0)
            {
                return;
            }
            EditorSubsystemManaged.getInstance().QueueAction(() =>
            {
                foreach (GameObject g in view.SelectedGameObjects)
                {
                    RayCastResult result = PhysicEngine.getInstance().RayCast3D_Output(g.transform.position, Vector3.Down, 1000);
                    if (result.hit)
                    {
                        g.transform.SetPosition(result.intersection);
                    }
                }
            });
        }
        void menu_item_Click(object sender, RoutedEventArgs e)
        {
            var menuitem = e.Source as MenuItem;
            EngineManagerViewModel view = (this.DataContext as EngineManagerViewModel);

            e.Handled = true;
            if (view.SelectedGameObjects.Count == 0)
            {
                return;
            }
            string compname = menuitem.DataContext as String;

            EditorSubsystemManaged.getInstance().QueueAction(() =>
            {
                foreach (GameObject g in view.SelectedGameObjects)
                {
                    g.RequireComponentByName(compname);
                }
                Dispatcher.Invoke(() =>
                {
                    ComponentListViewControl.GetBindingExpression(ListView.ItemsSourceProperty).UpdateTarget();
                });
            });
        }
Beispiel #8
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (_viewModel == null && this.DataContext != null)
         _viewModel = this.DataContext as EngineManagerViewModel;
 }
Beispiel #9
0
 public EngineManagerControl()
 {
     DataContext = new EngineManagerViewModel();
 }
 public EngineManagerControl()
 {
     DataContext = new EngineManagerViewModel();
 }