Example #1
0
        private void TryHitTerrainHandle(RaycastHit hit)
        {
            TerrainToolHandle handle = hit.collider.GetComponent <TerrainToolHandle>();

            if (m_pointerOverHandle != handle)
            {
                if (m_pointerOverHandle != null)
                {
                    m_pointerOverHandle.IsPointerOver = false;
                }

                m_pointerOverHandle = handle;

                if (m_pointerOverHandle != null)
                {
                    m_pointerOverHandle.IsPointerOver = true;
                }
            }
        }
Example #2
0
        private void InitHandles()
        {
            m_prevInterpolation = m_state.Interpolation;
            InitLerpGrid();

            if (m_handles != null)
            {
                foreach (KeyValuePair <GameObject, int> kvp in m_handles)
                {
                    GameObject handle = kvp.Key;
                    int        z      = kvp.Value / m_count;
                    int        x      = kvp.Value % m_count;
                    float      y      = m_state.Grid[kvp.Value] * m_activeTerrain.terrainData.heightmapScale.y;

                    handle.transform.position = new Vector3(x * m_state.Spacing, y, z * m_state.Spacing);
                }
            }
            else
            {
                m_handles = new Dictionary <GameObject, int>(m_state.Grid.Length);

                for (int x = 0; x < m_count; ++x)
                {
                    for (int z = 0; z < m_count; ++z)
                    {
                        m_handlePrefab.gameObject.SetActive(false);
                        TerrainToolHandle handle = Instantiate(m_handlePrefab, transform);
                        handle.gameObject.hideFlags = HideFlags.HideInHierarchy;

                        LockAxes lockAxes = handle.gameObject.AddComponent <LockAxes>();
                        lockAxes.PositionX = true;
                        lockAxes.PositionZ = true;

                        float y = m_state.Grid[z * m_count + x] * m_activeTerrain.terrainData.heightmapScale.y;
                        handle.transform.localPosition = new Vector3(x * m_state.Spacing, y, z * m_state.Spacing);
                        handle.name = "h " + x + "," + z;
                        handle.gameObject.SetActive(true);

                        m_handles.Add(handle.gameObject, z * m_count + x);
                    }
                }
            }
        }
Example #3
0
        private void OnSelectionChanged(Object[] unselectedObjects)
        {
            if (unselectedObjects != null)
            {
                foreach (Object obj in unselectedObjects)
                {
                    GameObject go = obj as GameObject;
                    if (go != null)
                    {
                        TerrainToolHandle handle = go.GetComponent <TerrainToolHandle>();
                        if (handle != null)
                        {
                            handle.IsSelected = false;
                        }
                    }
                }
            }

            if (m_editor.Selection.gameObjects == null || m_editor.Selection.gameObjects.Length == 0)
            {
                m_targetHandles = null;
            }
            else
            {
                m_targetHandles = m_editor.Selection.gameObjects.Where(go => go != null && m_handles.ContainsKey(go)).ToArray();
                foreach (GameObject go in m_targetHandles)
                {
                    TerrainToolHandle handle = go.GetComponent <TerrainToolHandle>();
                    handle.IsSelected = true;
                }
                if (m_targetHandles.Length == 0)
                {
                    m_targetHandles = null;
                }
            }
        }