Exemple #1
0
        /// <summary>
        ///     Entry point for rendering
        /// </summary>
        public void OnSceneGUI()
        {
            if (Event.current.ToString() == "used")
            {
                return;
            }
            if (Event.current.isMouse && Event.current.type == EventType.MouseDrag && Event.current.button == 1)
            {
                return;
            }

            EditorApplication.update -= Update;
            EditorApplication.update += Update;

            var roundedMin = GridManager.GetCellMin(Rect.min.x0z());
            var roundedMax = GridManager.GetCellMin(Rect.max.x0z());

            Rect = Rect.MinMaxRect(roundedMin.x, roundedMin.y, roundedMax.x, roundedMax.y);

            HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
            Tools.current = Tool.None;

            if (GridManager == null)
            {
                Debug.LogWarning("GridManager was null!");
                return;
            }

            var t  = EditorApplication.timeSinceStartup;
            var dt = (float)Mathfx.Clamp(t - _lastUpdate, double.Epsilon, 0.5);

            _lastUpdate = EditorApplication.timeSinceStartup;

            UpdateInputState();
            Paint(dt);
            UpdateVisualisation();

            SceneView.RepaintAll();
        }