Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ProjectPart.cs 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEditor.Compilation;
  4. using UnityEngine;
  5. namespace Packages.Rider.Editor.ProjectGeneration
  6. {
  7. internal class ProjectPart
  8. {
  9. public string Name { get; }
  10. public string OutputPath { get; }
  11. public Assembly Assembly { get; }
  12. public List<string> AdditionalAssets { get; }
  13. public string[] SourceFiles { get; }
  14. public string RootNamespace { get; }
  15. public Assembly[] AssemblyReferences { get; }
  16. public string[] CompiledAssemblyReferences { get; }
  17. public string[] Defines { get; }
  18. public ScriptCompilerOptions CompilerOptions { get; }
  19. public ProjectPart(string name, Assembly assembly, List<string> additionalAssets)
  20. {
  21. Name = name;
  22. Assembly = assembly;
  23. AdditionalAssets = additionalAssets;
  24. OutputPath = assembly != null ? assembly.outputPath : "Temp/Bin/Debug";
  25. SourceFiles = assembly != null ? assembly.sourceFiles : Array.Empty<string>();
  26. #if UNITY_2020_2_OR_NEWER
  27. RootNamespace = assembly != null ? assembly.rootNamespace : string.Empty;
  28. #else
  29. RootNamespace = UnityEditor.EditorSettings.projectGenerationRootNamespace;
  30. #endif
  31. AssemblyReferences = assembly != null ? assembly.assemblyReferences : Array.Empty<Assembly>();
  32. CompiledAssemblyReferences = assembly != null ? assembly.compiledAssemblyReferences : Array.Empty<string>();
  33. Defines = assembly != null ? assembly.defines : Array.Empty<string>();
  34. CompilerOptions = assembly != null ? assembly.compilerOptions : new ScriptCompilerOptions();
  35. }
  36. public List<ResponseFileData> GetResponseFileData(IAssemblyNameProvider assemblyNameProvider, string projectDirectory)
  37. {
  38. if (Assembly == null)
  39. return new List<ResponseFileData>();
  40. var data = new List<ResponseFileData>();
  41. foreach (var responseFile in Assembly.compilerOptions.ResponseFiles)
  42. {
  43. var responseFileData = assemblyNameProvider.ParseResponseFile(responseFile, projectDirectory, Assembly.compilerOptions.ApiCompatibilityLevel);
  44. foreach (var error in responseFileData.Errors)
  45. Debug.Log($"{responseFile} Parse Error : {error}");
  46. data.Add(responseFileData);
  47. }
  48. return data;
  49. }
  50. }
  51. }