Ejemplo n.º 1
0
        public static void LoadCurrentLocationData(LocationCreator window)
        {
            if (Object.FindObjectOfType <LocationHandler>() == null)
            {
                return;
            }

            window.currentActiveLocation = Object.FindObjectOfType <LocationHandler>().locationData;
        }
        public static void DuplicateLocation(LocationCreator window)
        {
            EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();


            bool isEmpty = window.CheckIfNewLocationNameIsEmpty();

            if (isEmpty == true)
            {
                window.SendLocationStringIsMissingMessage();
                return;
            }

            bool isExisting = window.CheckIfLocationExists();

            if (isExisting == true)
            {
                window.SendMessageLocationAlreadyExists();
                return;
            }

            string LocationRootPath       = "Assets/" + StaticProjectSettings.projectName + "/Scenes/Locations/";
            string guid                   = AssetDatabase.CreateFolder("Assets/" + StaticProjectSettings.projectName + "/Scenes/Locations", window.newLocationName);
            string locationObjectPathGuid = AssetDatabase.CreateFolder("Assets/" + StaticProjectSettings.projectName + "/Resources/Locations", window.newLocationName);
            string locationObjectPath     = AssetDatabase.GUIDToAssetPath(locationObjectPathGuid);
            string newFolderPath          = AssetDatabase.GUIDToAssetPath(guid);

            //Copy Settings Files
            window.CopySceneFile(LocationRootPath + window.selectedLocation + "/" + window.selectedLocation, "_Settings.unity", newFolderPath);
            //Copy Gameplay File
            window.CopySceneFile(LocationRootPath + window.selectedLocation + "/" + window.selectedLocation, "_Gameplay.unity", newFolderPath);
            //Copy Ground File
            window.CopySceneFile(LocationRootPath + window.selectedLocation + "/" + window.selectedLocation, "_Ground.unity", newFolderPath);
            //Copy Props File
            window.CopySceneFile(LocationRootPath + window.selectedLocation + "/" + window.selectedLocation, "_Props.unity", newFolderPath);
            //Copy Buildings File
            window.CopySceneFile(LocationRootPath + window.selectedLocation + "/" + window.selectedLocation, "_Buildings.unity", newFolderPath);
            //Copy Lighting File
            window.CopySceneFile(LocationRootPath + window.selectedLocation + "/" + window.selectedLocation, "_Lighting.unity", newFolderPath);
            //Copy Editor File
            window.CopySceneFile(LocationRootPath + window.selectedLocation + "/" + window.selectedLocation, "_Editor.unity", newFolderPath);
            //Create Location Object
            Location locationAsset = ScriptableObject.CreateInstance <Location>();

            locationAsset.locationName = window.newLocationName;

            AssetDatabase.CreateAsset(locationAsset, locationObjectPath + "/" + window.newLocationName + ".Asset");
            AssetDatabase.SaveAssets();
            AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(locationAsset), newFolderPath);
            AssetDatabase.Refresh();

            LocationHandler locationHandle = Object.FindObjectOfType <LocationHandler>();

            locationHandle.locationData = locationAsset;

            window.RefreshLocationsList();
        }
        public static void AddNewLocationToList(string locationName, LocationCreator window)
        {
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            LocationList locationList     = Resources.Load("Locations/Location List") as LocationList;
            string       LocationRootPath = "Locations";
            string       fullpath         = LocationRootPath + "/" + locationName + "/" + locationName;
            Location     locationData     = Resources.Load(fullpath) as Location;

            window.locationsList.locations.Add(locationData);
            AssetDatabase.SaveAssets();
            window.RefreshLocationsList();
        }
        public static void RefreshLocationsList(LocationCreator locationInterface)
        {
            locationInterface.locationsList = Resources.Load("Locations/Location List") as LocationList;
            locationInterface.locationsList.locations.Clear();
            Location[] arrayOfLocations = GetAllInstances <Location>();
            foreach (Location item in arrayOfLocations)
            {
                locationInterface.locationsList.locations.Add(item);
            }

            if (locationInterface.includeTestLocations == false)
            {
                for (int i = 0; i < locationInterface.locationsList.locations.Count; i++)
                {
                    if (locationInterface.locationsList.locations[i].isTestLocation == false)
                    {
                        locationInterface.availableLocations.Add(locationInterface.locationsList.locations[i].locationName);
                    }
                }
            }
            else
            {
                for (int i = 0; i < locationInterface.locationsList.locations.Count; i++)
                {
                    locationInterface.availableLocations.Add(locationInterface.locationsList.locations[i].locationName);
                }
            }

            if (locationInterface.selectedLocation == null)
            {
                locationInterface.selectedLocation = locationInterface.locationsList.locations[0].locationName;
            }

            if (Object.FindObjectOfType <LocationHandler>() != null)
            {
                locationInterface.currentActiveLocation = Object.FindObjectOfType <LocationHandler>().locationData;
            }
            if (locationInterface.currentActiveLocation == null)
            {
                if (Object.FindObjectOfType <LevelManager>() != null)
                {
                    locationInterface.currentActiveLocation = Object.FindObjectOfType <LevelManager>().locationData;
                }
                else
                {
                    Debug.Log("Scene Does Not Contain Level Manager or Location data");
                }
            }
        }
        public static void NewLocationSetup(string locationName, LocationCreator window)
        {
            string LocationRootPath = "Assets/" + StaticProjectSettings.projectName + "/Resources/Locations";
            string guid             = AssetDatabase.CreateFolder("Assets/" + StaticProjectSettings.projectName + "/Scenes/Locations", locationName);
            string newFolderPath    = AssetDatabase.GUIDToAssetPath(guid);

            string   locationObjectPathGuid = AssetDatabase.CreateFolder("Assets/" + StaticProjectSettings.projectName + "/Resources/Locations", locationName);
            string   locationObjectPath     = AssetDatabase.GUIDToAssetPath(locationObjectPathGuid);
            Location locationAsset          = window.CreateScriptableObjectLocation();

            locationAsset.locationName = locationName;
            if (window.markAsTestLocation)
            {
                locationAsset.isTestLocation = true;
            }
            AssetDatabase.CreateAsset(locationAsset, "Assets/" + StaticProjectSettings.projectName + "/Resources/Locations/" + locationName + "/" + locationName + ".Asset");

            string locationPath = "Assets/" + StaticProjectSettings.projectName + "/Resources/Locations/" + locationName + "/";

            AssetDatabase.SaveAssets();
            AssetDatabase.MoveAsset(AssetDatabase.GetAssetPath(locationAsset), locationObjectPath);
            //Create Settings Scene
            LocationCreator_CreateScene.CreateLocationScene(locationName, "_Settings", newFolderPath);
            //Create Gameplay Scene
            LocationCreator_CreateScene.CreateLocationScene(locationName, "_Gameplay", newFolderPath);
            //Create Ground Scene
            LocationCreator_CreateScene.CreateLocationScene(locationName, "_Ground", newFolderPath);
            //Create Props Scene
            LocationCreator_CreateScene.CreateLocationScene(locationName, "_Props", newFolderPath);
            //Create Buidlings Scene
            LocationCreator_CreateScene.CreateLocationScene(locationName, "_Buildings", newFolderPath);
            //Create Lighting Scene
            LocationCreator_CreateScene.CreateLocationScene(locationName, "_Lighting", newFolderPath);
            //Create Editor Scene
            LocationCreator_CreateScene.CreateLocationScene(locationName, "_Editor", newFolderPath);
            AssetDatabase.SaveAssets();
            //      locationInterface.locationsList.locations.Add(locationAsset);

            AddNewLocationToList(locationAsset.locationName, window);
            window.selectedLocation = locationAsset.locationName;
            window.LoadSelectedLocation();

            CreateLocationDataInScene(locationName, locationAsset, window);
        }
Ejemplo n.º 6
0
        public static void LoadSelectedLocation(LocationCreator window)
        {
            EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();

            string selectedLocation = window.selectedLocation;
            string LocationRootPath = "Assets/" + StaticProjectSettings.projectName + "/Scenes/Locations/";
            string fullpath         = LocationRootPath + selectedLocation + "/" + selectedLocation;

            //Load Master Scene
            if (window.includeMasterSceneWhenOpening == true)
            {
                EditorSceneManager.OpenScene("Assets/" + StaticProjectSettings.projectName + "/Scenes/Master/MasterScene.unity", OpenSceneMode.Single);
            }

            if (window.includeMasterSceneWhenOpening == true)
            {
                //Load Settings File
                EditorSceneManager.OpenScene(fullpath + "_Settings" + ".unity", OpenSceneMode.Additive);
            }
            else
            {
                EditorSceneManager.OpenScene(fullpath + "_Settings" + ".unity", OpenSceneMode.Single);
            }
            //Load Gameplay Scene
            EditorSceneManager.OpenScene(fullpath + "_Gameplay" + ".unity", OpenSceneMode.Additive);
            //Load Ground Scene
            EditorSceneManager.OpenScene(fullpath + "_Ground" + ".unity", OpenSceneMode.Additive);
            //Load Props Scene
            EditorSceneManager.OpenScene(fullpath + "_Props" + ".unity", OpenSceneMode.Additive);
            //Load Buildings Scene
            EditorSceneManager.OpenScene(fullpath + "_Buildings" + ".unity", OpenSceneMode.Additive);
            //Load Lighting Scene
            EditorSceneManager.OpenScene(fullpath + "_Lighting" + ".unity", OpenSceneMode.Additive);
            //Load Editor Scene
            EditorSceneManager.OpenScene(fullpath + "_Editor" + ".unity", OpenSceneMode.Additive);

            LoadCurrentLocationData(window);
#if Unity_Editor
            if (window.includeRevelevantLevelTypeDataSceneWhenOpening == true)
            {
                window.OpenReleventLevelTypeDataScene();
            }
#endif
        }
Ejemplo n.º 7
0
        private static void OpenLocationInteface()
        {
            window = GetWindow <LocationCreator>();

            //Load Locations List
            window.locationsList = Resources.Load("Locations/Location List") as LocationList;

            foreach (LocationList item in Resources.FindObjectsOfTypeAll(typeof(LocationList)) as LocationList[])
            {
                window.locationsList = item;
            }
            if (window.locationsList != null)
            {
                window.RefreshLocationsList();
            }

            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 500);
            window.RefreshLocationsList();
        }
Ejemplo n.º 8
0
        LocationCreator GetRefreshedWindowReference()
        {
            window = GetWindow <LocationCreator>();

            //Load Locations List
            window.locationsList = Resources.Load("Locations/Location List") as LocationList;

            foreach (LocationList item in Resources.FindObjectsOfTypeAll(typeof(LocationList)) as LocationList[])
            {
                window.locationsList = item;
            }
            if (window.locationsList != null)
            {
                window.RefreshLocationsList();
            }

            window.RefreshLocationsList();

            return(window);
        }
        public static void DeleteLocation(LocationCreator window)
        {
            EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
            string   fullpath     = "Locations" + "/" + window.selectedLocation + "/" + window.selectedLocation;
            Location locationData = Resources.Load(fullpath) as Location;

            window.locationsList.locations.Remove(locationData);
            string SceneRootPath = "Assets/" + StaticProjectSettings.projectName + "/Scenes/Locations/";
            string LocationPath  = "Assets/" + StaticProjectSettings.projectName + "/Resources/Locations/";

            for (int i = 0; i < window.availableLocations.Count; i++)
            {
                if (window.availableLocations[i].Text == window.selectedLocation)
                {
                    window.availableLocations.Remove(window.availableLocations[i]);
                }
            }
            FileUtil.DeleteFileOrDirectory(SceneRootPath + window.selectedLocation + "/");
            FileUtil.DeleteFileOrDirectory(LocationPath + window.selectedLocation + "/");
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            window.selectedLocation = window.locationsList.locations[0].locationName;
            window.RefreshLocationsList();
        }
        public static void CreateLocationDataInScene(string sceneName, Location locationData, LocationCreator creator)
        {
            GameObject geo = new GameObject();

            geo.name = "Location Data";
            LocationHandler locationHandler = geo.AddComponent <LocationHandler>();

            locationHandler.locationData = locationData;
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            SceneManager.MoveGameObjectToScene(geo, SceneManager.GetSceneByName(sceneName + "_Settings"));

            EditorSceneManager.SaveScene(SceneManager.GetSceneByName(sceneName + "_Settings"));

            creator.currentActiveLocation = locationHandler.locationData;
            LocationCreator_AddDataToLevel.CreateLevelManager(sceneName + "_Settings", locationData);
            LocationCreator_AddDataToLevel.CreateInputManager(sceneName + "_Settings");
            LocationCreator_AddDataToLevel.CreateDefaultLighting(sceneName + "_Lighting");
        }