Ejemplo n.º 1
0
        private void TryHitTerrainHandle(RaycastHit hit)
        {
            TerrainGridHandle handle = hit.collider.GetComponent <TerrainGridHandle>();

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

                m_pointerOverHandle = handle;

                if (m_pointerOverHandle != null)
                {
                    m_pointerOverHandle.IsPointerOver = true;
                }
            }
        }
Ejemplo n.º 2
0
        private void OnSelectionChanged(UnityObject[] unselectedObjects)
        {
            if (unselectedObjects != null)
            {
                foreach (UnityObject obj in unselectedObjects)
                {
                    GameObject go = obj as GameObject;
                    if (go != null)
                    {
                        TerrainGridHandle handle = go.GetComponent <TerrainGridHandle>();
                        if (handle != null)
                        {
                            handle.IsSelected = false;
                        }
                    }
                }
            }

            if (m_terrainHandlesSelection.Selection.gameObjects == null || m_terrainHandlesSelection.Selection.gameObjects.Length == 0)
            {
                m_selectedHandles = null;
            }
            else
            {
                IEnumerable <GameObject> selectedHandles = m_terrainHandlesSelection.Selection.gameObjects.Where(go => go != null && m_handleToKey.ContainsKey(go));
                foreach (GameObject go in selectedHandles)
                {
                    TerrainGridHandle handle = go.GetComponent <TerrainGridHandle>();
                    handle.IsSelected = true;
                }

                m_selectedHandles = selectedHandles.Select(go => m_handleToKey[go]).ToArray();
                if (m_selectedHandles.Length == 0)
                {
                    m_selectedHandles = null;
                }
            }
        }
Ejemplo n.º 3
0
        private void UpdateHandlePositions()
        {
            if (m_keyToHandle == null)
            {
                return;
            }

            TerrainData data   = TerrainData;
            int         xCount = Mathf.FloorToInt(m_xCount);
            int         zCount = Mathf.FloorToInt(m_zCount);

            for (int x = 0; x < xCount; ++x)
            {
                for (int z = 0; z < zCount; ++z)
                {
                    int hid = z * xCount + x;

                    TerrainGridHandle handle = m_keyToHandle[hid].GetComponent <TerrainGridHandle>();
                    float             y      = m_state.Grid[hid] * data.heightmapScale.y;
                    handle.transform.localPosition = new Vector3(x * m_state.XSpacing, y, z * m_state.ZSpacing);
                }
            }
        }