Hue Preserving Color Blending
PackageJsonHelper.cs
1 using System.IO;
2 using UnityEngine;
3 
5 {
6  internal class PackageJsonHelper
7  {
8  [SerializeField]
9  private string name = string.Empty;
10 
11  private string path = string.Empty;
12 
13  public static string GetPackagePath(string jsonPath)
14  {
15  return Path.GetDirectoryName(jsonPath).Replace("\\", "/");
16  }
17 
18  public static PackageJsonHelper Load(string path)
19  {
20  // If the path is a directory, find the `package.json` file path
21  var jsonPath = Directory.Exists(path) ? Path.Combine(path, "package.json") : path;
22  if (!File.Exists(jsonPath))
23  return null;
24  var packageJson = JsonUtility.FromJson<PackageJsonHelper>(File.ReadAllText(jsonPath));
25  packageJson.path = GetPackagePath(jsonPath);
26  return string.IsNullOrEmpty(packageJson.name) ? null : packageJson;
27  }
28 
30  {
31  get { return new PackageInfo {PackageId = string.Format("{0}@file:{1}", name, path)}; }
32  }
33  }
34 }