Пример #1
0
        // Appelé à chaque affichage de la SceneView
        private void OnSceneGUI()
        {
            _mesh = target as AdaptiveRail;

            if (ShowVertices)
            {
                ShowHandles();
            }
        }
Пример #2
0
        // Custom Inspector
        public override void OnInspectorGUI()
        {
            //
            GUILayout.Label("Default Inspector");

            DrawDefaultInspector();

            _mesh = target as AdaptiveRail;

            //
            GUILayout.Space(10f);
            GUILayout.Label("Vertices affectation");

            if (GUILayout.Button("Sélectionner les vertices"))
            {
                if (_selectionState == -1)
                {
                    _selectionState = 0; // par défaut

                    _mesh.SetRenderedMesh(AdaptiveRail.MeshSelection.Original);

                    // On récupère les liens des vertices venant de l'objet
                    _selectedBeginVertices = _mesh.beginVertices == null ? new HashSet <int>() : new HashSet <int>(_mesh.beginVertices);
                    _selectedEndVertices   = _mesh.endVertices == null ? new HashSet <int>() : new HashSet <int>(_mesh.endVertices);
                }
                else
                {
                    _selectionState = -1;

                    _mesh.SetRenderedMesh(AdaptiveRail.MeshSelection.Cloned);
                }

                // Actualise la vue
                SceneView.RepaintAll();
            }

            // En mode de sélection
            if (_selectionState != -1)
            {
                string[] choices = { "Begin", "End" };
                _selectionState = GUILayout.SelectionGrid(_selectionState, choices, 2);

                if (GUILayout.Button("Apply selection"))
                {
                    ApplySelection();
                }
            }

            if (GUILayout.Button("Link with curve"))
            {
                _mesh.InitVerticesOffset();
            }

            //
            GUILayout.Space(10f);
            GUILayout.Label("Actions");

            if (GUILayout.Button("Reset Mesh"))
            {
                _mesh.Reset();
                _selectedBeginVertices.Clear();
                _selectedEndVertices.Clear();
            }

            if (GUILayout.Button("Show vertices"))
            {
                _showVertices = !_showVertices;

                SceneView.RepaintAll();
            }
        }