I don't quite understand how the project works and how the code compiles and what could be preventing this. I have a code that needs data from SpriteLibrary. I didn't understand how to get the data I need from SpriteLibrary, so I created this method inside SpriteLibrary itself.
public void CopyLibraryFrom(SpriteLibrary sourceLibrary)
{
foreach (var sourceCategory in sourceLibrary.m_Library)
{
var targetCategory = new SpriteLibCategory
{
name = sourceCategory.name,
categoryList = new List<SpriteCategoryEntry>()
};
foreach (var sourceEntry in sourceCategory.categoryList)
{
var targetEntry = new SpriteCategoryEntry
{
name = sourceEntry.name,
sprite = sourceEntry.sprite
};
targetCategory.categoryList.Add(targetEntry);
}
m_Library.Add(targetCategory);
}
CacheOverrides();
RefreshSpriteResolvers();
The first problem I encountered was that Visual Studio automatically deleted this method and any changes I made in SpriteLibrary. But if I canceled the automatic deletion several times, the code would be saved. I put it down to the fact that Unity automatically updates SpriteLibrary and resets it to default. Is there any possibility to fully edit SpriteLibrary with normal saving? Or am I doing something wrong? I haven't opened Unity for a month and I have errors like "CopyLibraryFrom method is not present in SpriteLibrary" again. I opened it again, but now it says that SpriteLibrary is decompiled and I can't edit it in any way. How to fix it? I'm sure I'm doing it wrong, but how can I do it right? enter image description here
I just don't understand how to edit this now? Or what else can I do to make it work properly?
This seems to be (part of) a Package.
Unity checks for changes and restores the packages from cache (or downloads if not cached already)
A package installed from a registry is immutable, which means you can’t edit it. If you want to edit a package, you can make it mutable by copying it to your Projects folder. This package type is called an embedded package, and it overrides what’s in your package cache.
→ If you really require to modify one of these you could make it an embedded package by copying it from Library/PackageCache
into the Packages
folder.