Пример #1
0
        private void TryHitTerrainHandle(RaycastHit hit)
        {
            TerrainSelectionHandle handle = hit.collider.GetComponent <TerrainSelectionHandle>();

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

                m_pointerOverHandle = handle;

                if (m_pointerOverHandle != null)
                {
                    m_pointerOverHandle.IsPointerOver = true;
                }
            }
        }
Пример #2
0
        private void OnSelectionChanged(UnityObject[] unselectedObjects)
        {
            if (unselectedObjects != null)
            {
                foreach (UnityObject obj in unselectedObjects)
                {
                    GameObject go = obj as GameObject;
                    if (go != null)
                    {
                        TerrainSelectionHandle handle = go.GetComponent <TerrainSelectionHandle>();
                        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)
                {
                    TerrainSelectionHandle handle = go.GetComponent <TerrainSelectionHandle>();
                    handle.IsSelected = true;
                }

                m_selectedHandles = selectedHandles.Select(go => m_handleToKey[go]).ToArray();
                if (m_selectedHandles.Length == 0)
                {
                    m_selectedHandles = null;
                }
            }
        }
Пример #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;

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