예제 #1
0
        public IEnumerator DoUpdate_Co(Map map, int indexInMap, bool isExporting, AreaSpawner areaSpawner = null)
        {
            m_Leap         = GetComponentInChildren <MapLeap>();
            m_TreasureRoot = GetComponentInChildren <TreasureRootMark>();
            if (m_TreasureRoot != null)
            {
                IEnumerator treasureEnumerator = m_TreasureRoot.DoUpdate();
                if (treasureEnumerator != null)
                {
                    while (treasureEnumerator.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            yield return(null);

            map.LoadExtenInfo(this);
            m_MineralRoot = GetComponentInChildren <MineralRootMark>();
            if (m_MineralRoot != null)
            {
                IEnumerator mineralEnumerator = m_MineralRoot.DoUpdate();
                if (mineralEnumerator != null)
                {
                    while (mineralEnumerator.MoveNext())
                    {
                        yield return(null);
                    }
                }
            }
            yield return(null);

            if (m_Leap != null)
            {
                m_Leap.DoUpdate(areaSpawner.m_AreaUid);
            }
            m_OwnerMap           = map;
            m_OwnerAreaSpawner   = areaSpawner;
            transform.localScale = Vector3.one;            // 美术说Area不会有缩放
            if (m_OwnerAreaSpawner != null)
            {
                gameObject.name = m_OwnerAreaSpawner.GetAreaSpawnObjName();
            }
            Bounds areaAABB = new Bounds();

            MapEditorUtility.CaculateAABB(transform, ref areaAABB, isExporting);
            m_AABB     = areaAABB;
            m_Diameter = MathUtility.CaculateDiagonal(m_AABB);
            if (VoxelGrid != null)
            {
                VoxelGrid.DoUpdate(m_AABB);
            }

            _Debug.DoUpdate(this);
        }
예제 #2
0
        private void CalcuateAllPrefab(GameObject obj, Dictionary <int, UnitInfo> unitInfos)
        {
            if (obj == null)
            {
                return;
            }

            if (!obj.activeSelf || obj.hideFlags == HideFlags.DontSave)
            {
                return;
            }
            if (obj.GetComponent <SemaphoreMark>() || obj.GetComponent <IRootMark>() ||
                obj.GetComponent <TreasureInfoMark>())
            {
                return;
            }
            MapEditorUtility.SelectChildParticleSystem(obj);
            GameObject sourcePrefab = UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(obj);;

            if (sourcePrefab == null)
            {
                //TODO:继续往子节点进行遍历
                int childCount = obj.transform.childCount;
                if (childCount > 0)
                {
                    for (int iChild = 0; iChild < childCount; iChild++)
                    {
                        CalcuateAllPrefab(obj.transform.GetChild(iChild).gameObject, unitInfos);
                    }
                }
            }
            else
            {
                UnitInfo unitInfo = new UnitInfo();
                unitInfo.InstanceId = obj.GetInstanceID();
                unitInfo.Unit       = obj;
                MapEditorUtility.CaculateAABB(obj.transform, ref unitInfo.AABB);
                unitInfos.Add(unitInfo.InstanceId, unitInfo);
            }
        }