I filed this bug report today. Just reposting here in case anyone else runs into it. Webplayer throws an exception when a class inherits from a base class and defines a protected child class which inherits from a protected child of the base class and the constructor is called. This only affects Webplayer (editor and build). Tested in 4.5.1f3 Error: MethodAccessException: Error verifying InhertianceBug/Element_Broken/DataSet/Data:.ctor (): Method InhertianceBug/Element_Base_Broken/DataSet_Base/Data_Base:.ctor () is not accessible at 0x0001 Bug Case: 618671 Workaround: Child classes must be declared internal or public instead of protected. Code (csharp): using UnityEngine; using System.Collections; public class InhertianceBug : MonoBehaviour { protected Element_Broken element_broken_protected; protected Element_Works element_works_public; void Awake() { // Run in the editor in Webplayer mode. // Uncomment this to see the crash: // MethodAccessException: Error verifying InhertianceBug/Element_Broken/DataSet/Data:.ctor (): // Method InhertianceBug/Element_Base_Broken/DataSet_Base/Data_Base:.ctor () is not accessible at 0x0001 element_broken_protected = new Element_Broken(); // Comment the above and uncomment this line to see this version that doesn't crash in webplayer //element_works_public = new Element_Works(); } #region Broken -- Uses protected on DataSet and DataSet_Base public abstract class Element_Base_Broken { protected DataSet_Base dataSet; public Element_Base_Broken() {} protected abstract class DataSet_Base { protected Data_Base data; public DataSet_Base() { } public abstract class Data_Base { public Data_Base() { } } } } public class Element_Broken : Element_Base_Broken { public Element_Broken() : base() { dataSet = new DataSet(); } protected class DataSet : DataSet_Base { public DataSet(): base() { data = new Data(); } public class Data : Data_Base { public Data() : base() { } } } } #endregion #region Works -- Uses public on DataSet and DataSet_Base public abstract class Element_Base_Works { protected DataSet_Base dataSet; public Element_Base_Works() { } public abstract class DataSet_Base { protected Data_Base data; public DataSet_Base() { } public abstract class Data_Base { public Data_Base() { } } } } public class Element_Works : Element_Base_Works { public Element_Works() : base() { dataSet = new DataSet(); } public class DataSet : DataSet_Base { public DataSet() : base() { data = new Data(); } public class Data : Data_Base { public Data() : base() { } } } } #endregion }
Hi, Thank you for reporting this issue, our developers are already investigating it. Regards, Paulius QA Team
I also ran into this today, only in web player. I have a relatively complicated hierarchy of my own classes, but all were declared public.