I have two Scriptable Objectsa ScriptableObject that's already used extensively in my project:
public class SFXClip : ScriptableObject
{
public AudioClip clip;
// other properties
}
I want to extend it to a derived version something like this:
public class SFXRandom : SFXClip
{
[SerializeField] List<AudioClip> audioClips;
newoverride public AudioClip clip
{
get
{
return audioClips[Random.Range(0, audioClips.Count)];
}
}
}
When accessing the clip property from SFXRandom in another classBut of course, is does not return a random clip fromI can't do that without making the list butclip field on the original object into a clipvirtual property.
If I am looking for an explanation why using new won't hide the inherited member and/or suggestions for achievingdo that, I'll lose all the desired effectAudioClip references in existing SFXClip instances in my project's Assets.
To prove that this problem does not occur in vanilla C#:
Consider the following code:
public class Test1
{
public int x = 1;
}
public class Test2 : Test1
{
new public int x
{
get
{
return 2;
}
}
}
Now create an instance of both classes, print x and voila it works asIs there a way I would expect.can implement this change without losing that data?