public static Either <ErrorMsg, A> load <A>(PathStr loadPath) where A : Object { var path = loadPath.unityPath; var a = Resources.Load <A>(path); if (a) { return(a); } return(notFound <A>(path)); }
public static Tpl <IAsyncOperation, Future <Either <ErrorMsg, A> > > loadAsync <A>( PathStr loadPath ) where A : Object { var path = loadPath.unityPath; IResourceRequest request = new WrappedResourceRequest(Resources.LoadAsync <A>(path)); return(F.t( request.upcast(default(IAsyncOperation)), Future <Either <ErrorMsg, A> > .async( p => ASync.StartCoroutine(waitForLoadCoroutine <A>(request, p.complete, path)) ) )); }
public CodePreprocessorMenuItemsTest() { p_rootPath = new PathStr(Path.GetTempPath()) / "CodeProcessorTest"; var dirPath1 = new PathStr(Directory.CreateDirectory(p_rootPath / "TestDir1").FullName); var dirPath2 = new PathStr(Directory.CreateDirectory(dirPath1 / "TestDir2").FullName); p_emptyDir = new PathStr(Directory.CreateDirectory(dirPath1 / "TestDirEmpty").FullName); p_noCsFilesDir = new PathStr(Directory.CreateDirectory(dirPath1 / "TestDirNoCs").FullName); p_cs1 = createFile(p_rootPath / "testCs1.cs"); p_cs2 = createFile(dirPath2 / "testCs2.cs"); p_cs3 = createFile(dirPath1 / "testCs3.cs"); p_cs4 = createFile(dirPath1 / "testCs4.cs"); p_noneCsFile = createFile(new PathStr(p_noCsFilesDir / "testTxt1.txt")); }
public static Either <string, ImmutableList <PathStr> > getFilePaths(PathStr rootPath, string fileExt) { if (!Directory.Exists(rootPath)) { return((string.Equals($"*{rootPath.extension}", fileExt)).either( $"Not a '*.{fileExt}' file.", () => ImmutableList.Create(new PathStr(rootPath.path)) )); } var paths = Directory.GetFiles(rootPath, fileExt, SearchOption.AllDirectories) .Select(PathStr.a).ToImmutableList(); return((paths.Count > 0).either($"No '*.{fileExt}' files in directory.", () => paths)); }
public static string copyAssetAndGetPath <T>(T obj, PathStr path) where T : Object { var originalPath = AssetDatabase.GetAssetPath(obj); var newPath = path.unityPath + "/" + obj.name + Path.GetExtension(originalPath); if (Log.d.isVerbose()) { Log.d.verbose($"{nameof(AssetDatabaseUtils)}#{nameof(copyAssetAndGetPath)}: " + $"copying asset from {originalPath} to {newPath}"); } if (!AssetDatabase.CopyAsset(originalPath, newPath)) { throw new Exception($"Couldn't copy asset from {originalPath} to {newPath}"); } return(newPath); }
public static void CreateStagingManifest(ProjectParams Params, DeploymentContext SC) { if (!Params.Stage) { return; } var ThisPlatform = SC.StageTargetPlatform; ThisPlatform.GetFilesToDeployOrStage(Params, SC); // Get the build.properties file // this file needs to be treated as a UFS file for casing, but NonUFS for being put into the .pak file // @todo: Maybe there should be a new category - UFSNotForPak string BuildPropertiesPath = CombinePaths(SC.LocalRoot, "Engine/Build"); if (SC.StageTargetPlatform.DeployLowerCaseFilenames(true)) { BuildPropertiesPath = BuildPropertiesPath.ToLower(); } SC.StageFiles(StagedFileType.NonUFS, BuildPropertiesPath, "build.properties", false, null, null, true); // move the UE4Commandline.txt file to the root of the stage // this file needs to be treated as a UFS file for casing, but NonUFS for being put into the .pak file // @todo: Maybe there should be a new category - UFSNotForPak string CommandLineFile = "UE4CommandLine.txt"; if (SC.StageTargetPlatform.DeployLowerCaseFilenames(true)) { CommandLineFile = CommandLineFile.ToLower(); } SC.StageFiles(StagedFileType.NonUFS, GetIntermediateCommandlineDir(SC), CommandLineFile, false, null, "", true, false); if (!Params.CookOnTheFly && !Params.SkipCookOnTheFly) // only stage the UFS files if we are not using cook on the fly { ConfigCacheIni PlatformGameConfig = new ConfigCacheIni(SC.StageTargetPlatform.PlatformType, "Game", CommandUtils.GetDirectoryName(Params.RawProjectPath)); // Initialize cultures to stage. List <string> CulturesToStage = null; // Use parameters if provided. if (Params.CulturesToCook != null && Params.CulturesToCook.Count > 0) { CulturesToStage = Params.CulturesToCook; } // Use configuration if otherwise lacking cultures to stage. if (CulturesToStage == null || CulturesToStage.Count == 0) { if (PlatformGameConfig != null) { PlatformGameConfig.GetArray("/Script/UnrealEd.ProjectPackagingSettings", "CulturesToStage", out CulturesToStage); } } // Error if no cultures have been provided. if (CulturesToStage == null || CulturesToStage.Count == 0) { throw new AutomationException("No cultures were specified for cooking and packaging. This will lead to fatal errors when launching. Specify culture codes via commandline (-CookCultures=) or using project packaging settings (+CulturesToStage)."); } // Engine ufs (content) SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Config"), "*", true, null, null, false, !Params.UsePak(SC.StageTargetPlatform)); // TODO: Exclude localization data generation config files. if (Params.bUsesSlate) { if (Params.bUsesSlateEditorStyle) { SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Content/Editor/Slate"), "*", true, null, null, false, !Params.UsePak(SC.StageTargetPlatform)); } SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Content/Slate"), "*", true, null, null, false, !Params.UsePak(SC.StageTargetPlatform)); SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Content/Slate"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Content/Slate"), true, !Params.UsePak(SC.StageTargetPlatform)); } foreach (string Culture in CulturesToStage) { StageLocalizationDataForCulture(SC, Culture, CombinePaths(SC.LocalRoot, "Engine/Content/Localization/Engine"), null, !Params.UsePak(SC.StageTargetPlatform)); } SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.LocalRoot, "Engine/Plugins"), "*.uplugin", true, null, null, true, !Params.UsePak(SC.StageTargetPlatform)); // Game ufs (content) SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot), "*.uproject", false, null, CombinePaths(SC.RelativeProjectRootForStage), true, !Params.UsePak(SC.StageTargetPlatform)); SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Config"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Config"), true, !Params.UsePak(SC.StageTargetPlatform)); // TODO: Exclude localization data generation config files. SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Plugins"), "*.uplugin", true, null, null, true, !Params.UsePak(SC.StageTargetPlatform)); foreach (string Culture in CulturesToStage) { StageLocalizationDataForCulture(SC, Culture, CombinePaths(SC.ProjectRoot, "Content/Localization/Game"), CombinePaths(SC.RelativeProjectRootForStage, "Content/Localization/Game"), !Params.UsePak(SC.StageTargetPlatform)); } // Stage any additional UFS and NonUFS paths specified in the project ini files; these dirs are relative to the game content directory if (PlatformGameConfig != null) { var ProjectContentRoot = CombinePaths(SC.ProjectRoot, "Content"); var StageContentRoot = CombinePaths(SC.RelativeProjectRootForStage, "Content"); List <string> ExtraUFSDirs; if (PlatformGameConfig.GetArray("/Script/UnrealEd.ProjectPackagingSettings", "DirectoriesToAlwaysStageAsUFS", out ExtraUFSDirs)) { // Each string has the format '(Path="TheDirToStage")' foreach (var PathStr in ExtraUFSDirs) { var PathParts = PathStr.Split('"'); if (PathParts.Length == 3) { var RelativePath = PathParts[1]; SC.StageFiles(StagedFileType.UFS, CombinePaths(ProjectContentRoot, RelativePath), "*", true, null, CombinePaths(StageContentRoot, RelativePath), true, !Params.UsePak(SC.StageTargetPlatform)); } } } List <string> ExtraNonUFSDirs; if (PlatformGameConfig.GetArray("/Script/UnrealEd.ProjectPackagingSettings", "DirectoriesToAlwaysStageAsNonUFS", out ExtraNonUFSDirs)) { // Each string has the format '(Path="TheDirToStage")' foreach (var PathStr in ExtraNonUFSDirs) { var PathParts = PathStr.Split('"'); if (PathParts.Length == 3) { var RelativePath = PathParts[1]; SC.StageFiles(StagedFileType.NonUFS, CombinePaths(ProjectContentRoot, RelativePath)); } } } } StagedFileType StagedFileTypeForMovies = StagedFileType.NonUFS; if (Params.FileServer) { // UFS is required when using a file server StagedFileTypeForMovies = StagedFileType.UFS; } if (SC.StageTargetPlatform.StageMovies) { SC.StageFiles(StagedFileTypeForMovies, CombinePaths(SC.LocalRoot, "Engine/Content/Movies"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Engine/Content/Movies"), true, !Params.UsePak(SC.StageTargetPlatform)); SC.StageFiles(StagedFileTypeForMovies, CombinePaths(SC.ProjectRoot, "Content/Movies"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Content/Movies"), true, !Params.UsePak(SC.StageTargetPlatform)); } // eliminate the sand box SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Saved", "Cooked", SC.CookPlatform), "*", true, null, "", true, !Params.UsePak(SC.StageTargetPlatform)); // CrashReportClient is a standalone slate app that does not look in the generated pak file, so it needs the Content/Slate and Shaders/StandaloneRenderer folders Non-UFS // @todo Make CrashReportClient more portable so we don't have to do this if (SC.bStageCrashReporter && UnrealBuildTool.UnrealBuildTool.PlatformSupportsCrashReporter(SC.StageTargetPlatform.PlatformType) && !SC.DedicatedServer) { //If the .dat file needs to be staged as NonUFS for non-Windows/Linux hosts we need to change the casing as we do with the build properties file above. SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Content/Slate")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Shaders/StandaloneRenderer")); SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Content/Localization/ICU")); // Linux platform stages ICU in GetFilesToDeployOrStage(), accounting for the actual architecture if (SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Win64 || SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Win32 || SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Mac) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/ICU")); } // SSL libraries are only available for Win64 builds. // @see FPerforceSourceControlProvider::LoadSSLLibraries if (SC.StageTargetPlatform.PlatformType == UnrealTargetPlatform.Win64) { SC.StageFiles(StagedFileType.NonUFS, CombinePaths(SC.LocalRoot, "Engine/Binaries/ThirdParty/OpenSSL")); } } } }
public static Tpl <IAsyncOperation, Future <A> > loadAsyncIgnoreErrors <A>( PathStr loadPath, bool logOnError = true ) where A : Object => loadAsync <A>(loadPath).map2(future => future.dropError(logOnError));
public EditorAssetInfo(PathStr path, string guid) { this.path = path; this.guid = guid; }
public AssetLoader(string assetName, string assetRuntimeResourceDirectory, PathStr assetEditorResourceDirectory) { this.assetName = assetName; this.assetRuntimeResourceDirectory = assetRuntimeResourceDirectory; this.assetEditorResourceDirectory = assetEditorResourceDirectory; }
static PathStr createFile(PathStr path) { File.Create(path).Close(); return(path); }
public static Tpl <IAsyncOperation, Future <A> > loadAsyncIgnoreErrors <A>( PathStr loadPath, bool logOnError = true ) where A : Object => ResourceLoader.loadAsyncIgnoreErrors <ResourceReference <A> >(loadPath, logOnError) .map2(future => future.map(getReferenceFromResource));
public static Tpl <IAsyncOperation, Future <Either <ErrorMsg, A> > > loadAsync <A>( PathStr loadPath ) where A : Object => ResourceLoader.loadAsync <ResourceReference <A> >(loadPath) .map2(future => future.mapT(getReferenceFromResource));
public static Either <ErrorMsg, A> load <A>(PathStr loadPath) where A : Object => ResourceLoader.load <ResourceReference <A> >(loadPath).mapRight(getReferenceFromResource);
/// <summary> /// Given a full filepath including root, creates a document at that location relative to root. That is, /// if you pass in root/hello but the current root is home, it will create home. /// </summary> /// <param name="path">Must contain the full filepath, including root. Must include ".doc", ".dir".</param> /// <returns></returns> public static Document CreateFileFromString(string path) { if (!IsDoc(path) && !IsDir(path)) throw new Exception(); using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { string[] pathArray = path.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries); string currPath = string.Empty; // Skip the last because it's the filename for (int i = 0; i < pathArray.Length - 1; i++) { currPath = System.IO.Path.Combine(currPath, pathArray[i]); if (!isf.DirectoryExists(currPath + "")) isf.CreateDirectory(currPath + ""); } string fileName = pathArray[pathArray.Length - 1]; IsolatedStorageFileStream f = isf.CreateFile(System.IO.Path.Combine(currPath, fileName)); f.Close(); PathStr p = new PathStr(PathBase.Root); // Skip the first because "root" is already in the path. for (int i = 1; i < pathArray.Length; i++) p = p.NavigateIn(pathArray[i], ItemType.Default); return new Document(p); } }