Пример #1
0
        public static void SetObjects(List <Transition>[] allTransitions, string[] allIds)
        {
            VegetationSystemPro         system  = GameObject.FindObjectOfType <VegetationSystemPro>();
            PersistentVegetationStorage storage = system.PersistentVegetationStorage;

            for (int i = 0; i < allTransitions.Length; i++)
            {
                if (allTransitions[i] == null)
                {
                    continue;
                }
                foreach (Transition obj in allTransitions[i])
                {
                    storage.AddVegetationItemInstance(
                        allIds[i],
                        obj.pos,
                        obj.scale,
                        obj.rotation,
                        applyMeshRotation: true,
                        vegetationSourceID: VS_MM_id,
                        distanceFalloff: 1,
                        clearCellCache: true);
                }
            }

            //for (int i=0; i<system.VegetationCellList.Count; i++)
            //	system.VegetationCellList[i].ClearCache();

            system.RefreshBillboards();

                                #if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(storage.PersistentVegetationStoragePackage);
            UnityEditor.EditorUtility.SetDirty(system);
                                #endif
        }
Пример #2
0
        public static void SetObjects(List <ObjectPool.Transition>[] allTransitions, string[] allIds)
        {
            if (system == null)
            {
                system = GameObject.FindObjectOfType <VegetationSystemPro>();
            }
            if (system == null)
            {
                throw new System.Exception("MapMagic could not find Vegetation System in scene./n Add Window -> AwesomeTechnologies -> Vegetation System to scene");
            }

            PersistentVegetationStorage storage = system.PersistentVegetationStorage;

            PersistentVegetationStoragePackage storagePackage = system.PersistentVegetationStorage.PersistentVegetationStoragePackage;

            if (storagePackage == null)
            {
                throw new System.Exception("Vegetation System has no storage package assigned to be used with MapMagic./nAssign a Persistent Vegetation Storage Package to Persistent Vegetation Storage component and initialize it.");
            }

            for (int i = 0; i < allTransitions.Length; i++)
            {
                if (allTransitions[i] == null)
                {
                    continue;
                }

                var itemInfo = system.GetVegetationItemInfo(allIds[i]);
                if (itemInfo == null)
                {
                    throw new System.Exception("Item applied by MapMagic is not present in Vegetation System storage");
                }

                foreach (ObjectPool.Transition obj in allTransitions[i])
                {
                    storage.AddVegetationItemInstance(
                        allIds[i],
                        obj.pos,
                        obj.scale,
                        obj.rotation,
                        applyMeshRotation: true,
                        vegetationSourceID: VS_MM_id,
                        distanceFalloff: 1,
                        clearCellCache: true);
                }
            }

            //for (int i=0; i<system.VegetationCellList.Count; i++)
            //	system.VegetationCellList[i].ClearCache();
            //system.ClearCache();

            system.RefreshBillboards();

                                #if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(storagePackage);
            UnityEditor.EditorUtility.SetDirty(system);
                                #endif
        }
Пример #3
0
        public static void SetObjects(VegetationSystemPro system, List <Transition>[] allTransitions, string[] allIds)
        {
            PersistentVegetationStorage storage = system.PersistentVegetationStorage;

            //if (system.VegetationCellQuadTree == null) //could happen on scene loading or playmode change
            //	system.RefreshVegetationSystem();
            if (!system.InitDone)
            {
                system.enabled = true;
            }

            byte VS_MM_id = 15;             //15 for MapMagic, 18 for Voxeland

            for (int i = 0; i < allTransitions.Length; i++)
            {
                if (allTransitions[i] == null)
                {
                    continue;
                }
                foreach (Transition obj in allTransitions[i])
                {
                    storage.AddVegetationItemInstance(
                        allIds[i],
                        obj.pos,
                        obj.scale,
                        obj.rotation,
                        applyMeshRotation: true,
                        vegetationSourceID: VS_MM_id,
                        distanceFalloff: 1,
                        clearCellCache: true);
                }
            }

            //for (int i=0; i<system.VegetationCellList.Count; i++)
            //	system.VegetationCellList[i].ClearCache();

            system.RefreshBillboards();

                        #if UNITY_EDITOR
            if (storage.PersistentVegetationStoragePackage != null)
            {
                UnityEditor.EditorUtility.SetDirty(storage.PersistentVegetationStoragePackage);
            }
            UnityEditor.EditorUtility.SetDirty(system);
                        #endif
        }
        /// <summary>
        /// This will add a new instance of a vegetationItem to the PersistentVegetationStorage. The VegetationItemID is the one you get from the AddVegetationItem function or from an existing item in the VegetationPackage. You provide it with worldspace position and a vegetationSourceID. See PersistentVegetationStorageTools.cs for info about the vegetationSourceID.
        /// </summary>
        /// <param name="vegetationItemID"></param>
        /// <param name="worldPosition"></param>
        /// <param name="scale"></param>
        /// <param name="rotation"></param>
        /// <param name="applyMeshRotation"></param>
        /// <param name="vegetationSourceID"></param>
        /// <param name="distanceFalloff"></param>
        /// <param name="clearCellCache"></param>
        public static void AddVegetationItemInstance(string vegetationItemID, Vector3 worldPosition, Vector3 scale, Quaternion rotation, bool applyMeshRotation, byte vegetationSourceID, float distanceFalloff, bool clearCellCache = true)
        {
            if (!Instance)
            {
                FindInstance();
            }

            if (Instance)
            {
                for (int i = 0; i <= Instance.VegetationSystemList.Count - 1; i++)
                {
                    PersistentVegetationStorage persistentVegetationStorage = Instance.VegetationSystemList[i].PersistentVegetationStorage;
                    if (persistentVegetationStorage)
                    {
                        persistentVegetationStorage.AddVegetationItemInstance(vegetationItemID, worldPosition, scale, rotation, applyMeshRotation, vegetationSourceID, distanceFalloff, clearCellCache);
                    }
                }
            }
        }