public static void LoadModule() { CheckGameObjectsPresetInScene <InputSingleTouch> checkGameObject = new CheckGameObjectsPresetInScene <InputSingleTouch>(); GameObjectSearchResult gSearchResult = checkGameObject.CheckForGameObject(); GameObject gObj = null; if (gSearchResult.numberOfObjects >= 1) { gObj = gSearchResult.foundGameObjects[0]; if (gObj != null) { gObj.SetActive(true); } if (gSearchResult.numberOfObjects > 1) { for (int i = 1; i < gSearchResult.foundGameObjects.Count; i++) { DestroyImmediate(gSearchResult.foundGameObjects[i]); } } Show_ObjectAlreadyExist(); } else { CreatePrefabInstance createPrefab = new CreatePrefabInstance("Prefabs/Input"); } }
private static void Update() { CheckGameObjectsPresetInScene <SingletonObject> singleton = new CheckGameObjectsPresetInScene <SingletonObject>(); GameObjectSerachResult result = singleton.CheckForGameObject(); if (result.numberOfObjects > 1) { List <GameObject> gObjs = result.foundGameObjects; int index = 0; for (int i = 0; i < gObjs.Count; i++) { SingletonTypes t = gObjs[i].GetComponent <SingletonObject>().type; if (allSingletonTypes.ContainsKey(t)) { duplicateObjects.Add(gObjs[i]); index++; } else { allSingletonTypes.Add(t, gObjs[i]); } } } for (int i = 0; i < duplicateObjects.Count; i++) { DestroyImmediate(duplicateObjects[i]); } duplicateObjects.Clear(); allSingletonTypes = new Dictionary <SingletonTypes, GameObject>(); }
public static void ExportUnityPackage() { DirectoryInfo di = new DirectoryInfo(Application.dataPath); string exportDirectory = di.Parent.FullName + "/Exported Packages"; if (!Directory.Exists(exportDirectory)) { Directory.CreateDirectory(exportDirectory); } if (EditorUtility.DisplayDialog("Export UnityPackage", "Do you want to start exporting a package from your current project?", "Yes", "No")) { CheckGameObjectsPresetInScene <ExportHelper> exportHelper = new CheckGameObjectsPresetInScene <ExportHelper>(); GameObjectSerachResult result = exportHelper.CheckForGameObject(); if (result.numberOfObjects >= 1) { string packageFolderName = result.foundGameObjects[0].GetComponent <ExportHelper>().PackageFolder; string exportedPackageName = result.foundGameObjects[0].GetComponent <ExportHelper>().ExportedPackageName; if (!string.IsNullOrEmpty(packageFolderName)) { while (string.IsNullOrEmpty(exportedPackageName)) { if (EditorUtility.DisplayDialog("Empty Export Package Name", "Given Export Package name is empty. Do you want to name your exported file with the given foldername?", "Yes", "No")) { exportedPackageName = packageFolderName; } } Debug.Log("AssetName = " + Application.dataPath + "/" + packageFolderName + ConvertDateTimeToString.StringFromDateTime() + ".unitypackage"); if (Directory.Exists(Application.dataPath + "/" + packageFolderName)) { AssetDatabase.ExportPackage("Assets/" + packageFolderName, exportDirectory + "/" + exportedPackageName + ConvertDateTimeToString.StringFromDateTime() + ".unitypackage", ExportPackageOptions.IncludeDependencies | ExportPackageOptions.Recurse); EditorUtility.DisplayDialog("Package exported", "Package successfully exported to " + exportDirectory + ".", "Ok"); AssetDatabase.Refresh(); } else { //Warn that directory does not exist EditorUtility.DisplayDialog("Directory does not exist", "Your specified directory does not exist", "Ok"); } } else { //Warn that no package folder name is specified EditorUtility.DisplayDialog("Export package folder unspecified", "No package folder name is specified. Enter the name of the package you want to export and try again", "Ok"); } } else { //Create export helper //Ask to try again EditorUtility.DisplayDialog("Export Helper Not found", "No export helper present in scene. Now one has been created. Enter correct Folder name and try again", "Ok"); CreatePrefabInstance createPrefab = new CreatePrefabInstance("Prefabs/ExportHelper"); } } }
public static void CreateCoreEngine() { Debug.Log("Engine created"); if (EditorUtility.DisplayDialog("Create Core Engine", "Do you want to create the core of Sourav Engine?", "Yes", "No")) { CheckGameObjectsPresetInScene <EngineId> engineID = new CheckGameObjectsPresetInScene <EngineId>(); GameObjectSerachResult result = engineID.CheckForGameObject(); if (result.numberOfObjects >= 1) { EditorUtility.DisplayDialog("ERROR!", "An instance of the Core Engine is already present in scene. No more is created.", "Ok"); } else { CreatePrefabInstance createPrefab = new CreatePrefabInstance("Prefabs/Engine"); EditorUtility.DisplayDialog("SUCCESS!", "Core Engine created. All the best with the rest of the Game!", "Ok"); } } }
public static void CreateCoreEngine() { Debug.Log("Orientation Manager created"); if (EditorUtility.DisplayDialog("Create Orientation Manager", "Do you want to create Orientation Manager?", "Yes", "No")) { CheckGameObjectsPresetInScene <OrientationManager> id = new CheckGameObjectsPresetInScene <OrientationManager>(); GameObjectSerachResult result = id.CheckForGameObject(); if (result.numberOfObjects >= 1) { EditorUtility.DisplayDialog("ERROR!", "An instance of the Orientation Manager is already present in scene. No more is created.", "Ok"); } else { CreatePrefabInstance createPrefab = new CreatePrefabInstance("Prefabs/OrientationManager"); EditorUtility.DisplayDialog("SUCCESS!", "Orientation Manager created. All the best with the rest of the Game!", "Ok"); } } }
static void Init() { if (Instance == null) { Instance = GetWindow <UIModule>(); Instance.Show(); } else { Instance.Focus(); } //Check For Singleton UIContainer CheckGameObjectsPresetInScene <UIContainer> checkGameObject = new CheckGameObjectsPresetInScene <UIContainer>(); GameObjectSearchResult gSearchResult = checkGameObject.CheckForGameObject(); GameObject gObj = null; if (gSearchResult.numberOfObjects >= 1) { gObj = gSearchResult.foundGameObjects[0]; if (gObj != null) { gObj.SetActive(true); } if (gSearchResult.numberOfObjects > 1) { for (int i = 1; i < gSearchResult.foundGameObjects.Count; i++) { DestroyImmediate(gSearchResult.foundGameObjects[i]); } } Show_ObjectAlreadyExist("UI Container Module"); } else { CreatePrefabInstance createPrefab = new CreatePrefabInstance("Prefabs/UIContainer"); } //Check For Singleton ScreenManager CheckGameObjectsPresetInScene <ScreenManager> checkGameObject2 = new CheckGameObjectsPresetInScene <ScreenManager>(); GameObjectSearchResult gSearchResult2 = checkGameObject2.CheckForGameObject(); GameObject gObj2 = null; if (gSearchResult2.numberOfObjects >= 1) { gObj2 = gSearchResult2.foundGameObjects[0]; if (gObj2 != null) { gObj2.SetActive(true); } if (gSearchResult2.numberOfObjects > 1) { for (int i = 1; i < gSearchResult2.foundGameObjects.Count; i++) { DestroyImmediate(gSearchResult2.foundGameObjects[i]); } } Show_ObjectAlreadyExist("ScreenManager Module"); } else { CreatePrefabInstance createPrefab = new CreatePrefabInstance("Prefabs/ScreenManager"); } }