ERROR: CreateInstanceFromType

cmiller
Member
Registered: 2014-12-08
Posts: 17

Topic

Hi There,

I've recently upgraded to Unity 5.4, and Rotorz 2.4.4, and I'm seeing this error. Is there anything I can do about it from my end?

CreateInstanceFromType is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'AssetSettingManagement'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ScriptableObject:CreateInstance()
Rotorz.Tile.Editor.AssetSettingManagement:.cctor()

Thanks a bunch!

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 1

Hi

That is very strange; because the AssetSettingManagement class does not have a static constructor (nor a regular constructor for that matter). I have forwarded this error to Unity to learn more about what really triggers it.

Could you please provide steps that I can follow to reproduce this problem.

Also, which version of Unity 5.4 are you using? f5.4.0f3 or f5.4.0p1 or f5.4.0p2 or other?

Many thanks

Last edited by Lea Hayes (2016-08-25 20:03:24)

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 2

I've been playing around with various combinations for over an hour now but I am unable to reproduce the problem that you mentioned. Steps to reproduce starting from an empty project would be very helpful :)

cmiller
Member
Registered: 2014-12-08
Posts: 17

Response 3

Thank you so much for looking into this.

I'm not sure what caused the error, but I managed to get rid of it by uninstalling Rotorz, and reinstalling again.

Thanks again, and TGIF!!

AndyGFX
Member
From: Slovakia
Registered: 2015-10-27
Posts: 24
Website

Response 4

Hi,

today tried add to my project RTS (latest version) on U5.4.f3 and I got this error, looks like desc. above. Instalation was made in project, where RTS wasn't  before.

CreateInstanceFromType is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'DesignerWindow'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ScriptableObject:CreateInstance()
Rotorz.Tile.Editor.AssetSettingManagement:get_Instance()
Rotorz.Tile.Editor.AssetSettingManagement:GetGroup(String)
Rotorz.Tile.Editor.DesignerWindow:.cctor()

EDIT#1: When I create any Autotile brush, then in Brushes windows is created duplication. When is selected then is hilited both, looks like same instance are selected and in console is error: CreateInstanceFromType is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'DesignerWindow'.

EDIT#2: Strange is, that I have another project with updated RTS and with this error too. Errors is showed always when is any brush selected in Brushes window first time.

Best regards,
AndyGFX

Last edited by AndyGFX (2016-09-18 12:16:34)

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 5

AndyGFX wrote:

today tried add to my project RTS (latest version) on U5.4.f3 and I got this error, looks like desc. above. Instalation was made in project, where RTS wasn't  before.

CreateInstanceFromType is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'DesignerWindow'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ScriptableObject:CreateInstance()
Rotorz.Tile.Editor.AssetSettingManagement:get_Instance()
Rotorz.Tile.Editor.AssetSettingManagement:GetGroup(String)
Rotorz.Tile.Editor.DesignerWindow:.cctor()

The UnityEngine.ScriptableObject:CreateInstance() issue should be fixed in the next Rotorz Tile System update. Unity is showing a message in the console when Rotorz Tile System first loads it's configuration due to a change they made in serialization.

AndyGFX wrote:

EDIT#1: When I create any Autotile brush, then in Brushes windows is created duplication. When is selected then is hilited both, looks like same instance are selected and in console is error: CreateInstanceFromType is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'DesignerWindow'.

With regards to your other issue, please update Unity to 5.4.0p4 (patch 4) where they have fixed their multi-object asset file bug.

AndyGFX
Member
From: Slovakia
Registered: 2015-10-27
Posts: 24
Website

Response 6

Hi,

do you have plan update release for Unity version 5.5.1(p2)?

Looks like same bug is back:

CreateInstanceFromType is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'DesignerWindow'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ScriptableObject:CreateInstance()
Rotorz.Tile.Editor.AssetSettingManagement:get_Instance()
Rotorz.Tile.Editor.AssetSettingManagement:GetGroup(String)
Rotorz.Tile.Editor.DesignerWindow:.cctor

Best regards,
AndyGFX

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 7

Thanks for reporting this. Do you know whether the issue occurred for you in Unity 5.5.1 (non-patch)?

AndyGFX
Member
From: Slovakia
Registered: 2015-10-27
Posts: 24
Website

Response 8

Hi,

sorry I have now all Unity instalations (x32,x64) patched :(

Note: I had a big Unity crash problem with my project (maybe unity issue or one from instaled asset), and now I have to start again from zero but with Rotorz Tile System, instead my previous tile editor.

Best regards,
AndyGFX

Last edited by AndyGFX (2017-02-04 18:34:14)

AndyGFX
Member
From: Slovakia
Registered: 2015-10-27
Posts: 24
Website

Response 9

Hi,

I found one 5.5.0 instalation and YES, I found same error in console. Looks like issue from 5.5.x.

AndyGFX

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 10

I am unable to reproduce the issue that you mentioned with Unity 5.5.1f1 nor in 5.5.1p1. I am wondering if something else in your project is using reflection to access all static classes (thus invoking static constructors from the wrong place).

Edit: It seems to occur at random; not sure what's causing it yet.

Are you working on Windows or OSX?

AndyGFX wrote:

Note: I had a big Unity crash problem with my project (maybe unity issue or one from instaled asset), and now I have to start again from zero but with Rotorz Tile System, instead my previous tile editor.

You lost your entire project?! wow, if so, please look into source control!!

AndyGFX
Member
From: Slovakia
Registered: 2015-10-27
Posts: 24
Website

Response 11

Hi,

1)
I'm on Windows 10 Pro.
Problem is when project is first time opened and then always when I change any source (after compilation finishing + reloaded assemblies)

2)

Yes I have all on SVN server,but looking where is problem in huge project is crazy if I have used a lot of 3rd assets/plugins and when Unity crash for example when I drag scene object to create prefab. Without crash information is it impossible. Log file shows only lines from console, where is not important infos. Error log has info about memory leak only. :(

Andy.

AndyGFX
Member
From: Slovakia
Registered: 2015-10-27
Posts: 24
Website

Response 12

HI,

I found when is problem.

I have Unity windows on 3 displays. One monitor has console, project and RTS Tools, Scene and Brushes window. Currently is empty.
When I start simple scene, or compile source I get error described above in my post.
2017-02-04%20%282%29.png?dl=1

When I close RTS windows and run scene or compile any source, then is all OK. No errors.

After reloading Layout I got 2 errors, but only once (on image below - left side).

2017-02-04%20%281%29.png?dl=1
Best regards,
AndyGFX

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 13

I have added a workaround to this issue and submitted to the Unity Asset Store for approval.

Thanks again for raising this issue with me!

Lea Hayes
Rotorz Limited
From: United Kingdom
Registered: 2014-03-04
Posts: 638

Response 14

This should be patched in the latest version of Rotorz Tile System v2.4.5 on the Unity Asset Store.

Please let me know how it goes!