public override sealed void OnImportAsset(AssetImportContext ctx) { m_CachedDatabase.Clear(); m_Errors.Clear(); m_Warnings.Clear(); m_MissingSortingLayers.Clear(); m_MissingLayers.Clear(); m_SuperAsset = null; AssetImportContext = ctx; try { InternalOnImportAsset(); } catch (TiledException tiled) { // Exceptions that SuperTiled2Unity is aware of // These are the kind of errors a user should be able to fix this.m_Errors.Add(tiled.Message); } catch (XmlException xml) { // Xml exceptions are common if the Tiled data file somehow becomes corrupted m_Errors.Add("Asset file may contained corrupted XML data. Trying opening in Tiled Map Editor to resolve."); m_Errors.Add(xml.Message); } catch (Exception ex) { // Last-chance collection of unknown errors while importing // This should be reported for bug fixing m_Errors.Add("Unknown error encountered. Please report as bug. Stack track is in the console output."); m_Errors.Add(ex.Message); Debug.LogErrorFormat("Unknown error of type {0}: {1}\nStack Trace:\n{2}", ex.GetType(), ex.Message, ex.StackTrace); } }
public void TrackDependencies(string assetPath) { SuperAsset super = AssetDatabase.LoadAssetAtPath <SuperAsset>(assetPath); if (super != null) { // Keep track of our dependencies AssetDependencies depends = AcquireAssetDependencies(assetPath); depends.AssignDependencies(super.AssetDependencies); // Remove our reference from all other assets foreach (var dep in m_AssetDependencies.Values) { dep.RemoveReference(assetPath); } // Add our reference to assets we are now dependent on foreach (var path in super.AssetDependencies) { AssetDependencies reference = AcquireAssetDependencies(path); reference.AddReference(assetPath); } } }
protected void AddSuperAsset <T>() where T : SuperAsset { m_SuperAsset = ScriptableObject.CreateInstance <T>(); m_SuperAsset.name = Path.GetFileNameWithoutExtension(assetPath); AssetImportContext.AddObjectToAsset("_superAsset", m_SuperAsset); }