/// <summary> /// Reload the currently selected asset as a .nuspec file. /// </summary> protected void Reload() { var defaultAsset = Selection.activeObject as DefaultAsset; if (defaultAsset != null) { var assetFilepath = AssetDatabase.GetAssetPath(defaultAsset); var dataPath = Application.dataPath.Substring(0, Application.dataPath.Length - "Assets".Length); assetFilepath = Path.Combine(dataPath, assetFilepath); var isNuspec = Path.GetExtension(assetFilepath) == ".nuspec"; if (!isNuspec || nuspec != null && filepath == assetFilepath) { return; } filepath = assetFilepath; nuspec = NuspecFile.Load(filepath); titleContent = new GUIContent(Path.GetFileNameWithoutExtension(filepath)); // force a repaint Repaint(); } }
/// <summary> /// Automatically called by Unity when the Inspector is first opened (when a .nuspec file is clicked on in the Project view). /// </summary> public void OnEnable() { filepath = AssetDatabase.GetAssetPath(target); string dataPath = Application.dataPath.Substring(0, Application.dataPath.Length - "Assets".Length); filepath = Path.Combine(dataPath, filepath); isNuspec = Path.GetExtension(filepath) == ".nuspec"; if (isNuspec) { nuspec = NuspecFile.Load(filepath); } }