Esempio n. 1
0
 private void Update()
 {
     if (!FocusOnInputField)
     {
         if (Input.GetKeyDown(KeyCode.E))
         {
             if (SelectedGameObject != null)
             {
                 SelectedGameObject.GetComponent <IWorldComponent>().OpenEditorWindow();
             }
             else
             {
                 Debug.Log("Nothing to edit!");
             }
         }
         else if (Input.GetKeyDown(KeyCode.Escape))
         {
             SelectedGameObject = null;
         }
         else if (Input.GetKeyDown(KeyCode.Delete))
         {
             // TODO: Delete the selected gameobject
         }
     }
 }
Esempio n. 2
0
 private void Components_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     this.Dispatcher.Invoke((Action)(() => {
         if (SelectedGameObject != null)
         {
             RenderComponent rc = SelectedGameObject.GetComponent <RenderComponent>();
             if (rc != null)
             {
                 Binding materialBinding = new Binding("material");
                 materialBinding.Source = rc;
                 MaterialEditor.SetBinding(MaterialInspector.MaterialProperty, materialBinding);
             }
             else
             {
                 BindingOperations.ClearBinding(MaterialEditor, MaterialInspector.MaterialProperty);
             }
         }
     }));
 }
Esempio n. 3
0
 private void GameObjectInspector_Loaded(object sender, RoutedEventArgs e)
 {
     gameObjectGrid.Visibility = Visibility.Hidden;
     if (SelectedGameObject != null)
     {
         gameObjectGrid.DataContext = SelectedGameObject;
         gameObjectGrid.Visibility  = Visibility.Visible;
         //Expand();
         //CreatePropertyGrids();
         SelectedGameObject.Components.CollectionChanged += Components_CollectionChanged;
         prevGameObject = SelectedGameObject;
         RenderComponent rc = SelectedGameObject.GetComponent <RenderComponent>();
         if (rc && rc.material != null)
         {
             Binding materialBinding = new Binding("material");
             materialBinding.Source = rc;
             MaterialEditor.SetBinding(MaterialInspector.MaterialProperty, materialBinding);
         }
     }
 }
Esempio n. 4
0
        private void DisplayUtilityButtons()
        {
            var autoUpdate = Configuration.GetBool("objExpAutoUpdate", false);
            var style      = autoUpdate ? Elements.Buttons.Default
                                   : Elements.Buttons.Disabled;

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Destroy"))
            {
                Destroy(SelectedGameObject);
            }
            if (GUILayout.Button("Toggle Highlight"))
            {
                var renderer = SelectedGameObject?.GetComponent <Renderer>();
                if (highlighted == renderer)
                {
                    highlighted.material.color = previousColor;
                    highlighted = null;
                }
                else if (renderer != null)
                {
                    highlighted   = renderer;
                    previousColor = highlighted.material.color;
                    highlighted.material.color = Color.yellow;
                }
            }
            if (GUILayout.Button("Select object with mouse"))
            {
                selecting = true;
            }
            if (GUILayout.Button("Auto Update", style))
            {
                Configuration.SetBool("objExpAutoUpdate", !autoUpdate);
            }
        }