Issue in ResourceManager

More
8 years 11 months ago #634 by Melser
I have issue:
UnityException: You are not allowed to call this function when declaring a variable.
Move it to the line after without a variable declaration.
If you are using C# don't use this function in the constructor or field initializers, Instead move initialization to the Awake or Start function.
UnityEngine.Object.FindObjectOfType (System.Type type) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:115)
I2.Loc.ResourceManager.get_pInstance () (at Assets/I2/Localization/Scripts/ResourceManager.cs:14)
I2.Loc.LocalizationManager.RegisterSourceInResources () (at Assets/I2/Localization/Scripts/LocalizationManager.cs:193)
I2.Loc.LocalizationManager.UpdateSources () (at Assets/I2/Localization/Scripts/LocalizationManager.cs:165)
I2.Loc.LocalizationManager.InitializeIfNeeded () (at Assets/I2/Localization/Scripts/LocalizationManager.cs:47)
I2.Loc.LocalizationManager.TryGetTermTranslation (System.String Term, System.String& Translation, Boolean FixForRTL) (at Assets/I2/Localization/Scripts/LocalizationManager.cs:131)
I2.Loc.LocalizationManager.GetTermTranslation (System.String Term, Boolean FixForRTL) (at Assets/I2/Localization/Scripts/LocalizationManager.cs:119)
I2.Loc.ScriptLocalization.Get (System.String Term, Boolean FixForRTL) (at Assets/I2/Localization/Scripts/ScriptLocalization.cs:8)

Can you help me with this problem. Because it's driving me crazy. :) My build 2.4.5 f3 and Unity 5.0.1f1

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #647 by Frank
Replied by Frank on topic Issue in ResourceManager
Hi,

I have been trying to reproduce your issue but I haven't found a way to do it.

Can you please tell me if you get that error within the editor or when deploying a build.
What platform is your project using (WebPlayer, WebGL, IOS, Android, etc).

And it will help A LOT if you list a set of steps to reproduce that issue.

I see that it happens when calling GetTermTranslation(xx), so I opened the example scene "UnityStandard Localization" and execute it both in the editor and in the device. That scenes calls GetTermTranslation(...) to translate the player's color so it should be producing that error you listed. However I'm not getting any issue.

I'm also on Unity 5.0.1f1

Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #648 by Melser
Replied by Melser on topic Issue in ResourceManager
This error I have in editor. My project type is Standalone x86_64
And I have StackTrace for this error, maybe it help you:

ResourceManager I2.Loc.ResourceManager:get_pInstance ()+0x0 at D:\depot\Client\Unity_Fishing_MainClient\Assets\I2\Localization\Scripts\ResourceManager.cs:13 C#
Void I2.Loc.LocalizationManager:RegisterSourceInResources ()+0x11 at D:\depot\Client\Unity_Fishing_MainClient\Assets\I2\Localization\Scripts\LocalizationManager.cs:193 C#
Boolean I2.Loc.LocalizationManager:UpdateSources ()+0x5 at D:\depot\Client\Unity_Fishing_MainClient\Assets\I2\Localization\Scripts\LocalizationManager.cs:165 C#
Void I2.Loc.LocalizationManager:InitializeIfNeeded ()+0xf at D:\depot\Client\Unity_Fishing_MainClient\Assets\I2\Localization\Scripts\LocalizationManager.cs:47 C#
Boolean I2.Loc.LocalizationManager:TryGetTermTranslation (String, String, Boolean)+0x14 at D:\depot\Client\Unity_Fishing_MainClient\Assets\I2\Localization\Scripts\LocalizationManager.cs:131 C#
String I2.Loc.LocalizationManager:GetTermTranslation (String, Boolean)+0x4 at D:\depot\Client\Unity_Fishing_MainClient\Assets\I2\Localization\Scripts\LocalizationManager.cs:119 C#
String I2.Loc.ScriptLocalization:Get (String, Boolean)+0x2 at D:\depot\Client\Unity_Fishing_MainClient\Assets\I2\Localization\Scripts\ScriptLocalization.cs:8 C#
> Void BaseFilter:.ctor ()+0x35 at D:\depot\Client\Unity_Fishing_MainClient\Assets\Scripts\UI\2D\Shop\Filters\BaseFilter.cs:18 C#
Void ConcreteRodFilter:.ctor ()+0x1 at D:\depot\Client\Unity_Fishing_MainClient\Assets\Scripts\UI\2D\Shop\Filters\ConcreteRodFilter.cs:-1 C#
Void RodFilter:.ctor ()+0x1 at D:\depot\Client\Unity_Fishing_MainClient\Assets\Scripts\UI\2D\Shop\Filters\RodFilter.cs:-1 C#
Boolean UnityEditor.AssetDatabase:OpenAsset (Int32)+0x4 at C:\buildslave\unity\build\artifacts\generated\common\editor\AssetDatabaseBindings.gen.cs:229 C#
Void UnityEditor.ProjectBrowser:OpenAssetSelection (Int32[])+0x19 at C:\buildslave\unity\build\Editor\Mono\ProjectBrowser.cs:966 C#
Void UnityEditor.ProjectBrowser:AssetTreeItemDoubleClickedCallback (Int32)+0x5 at C:\buildslave\unity\build\Editor\Mono\ProjectBrowser.cs:1125 C#
Void UnityEditor.TreeView:HandleUnusedMouseEventsForNode (Rect, TreeViewItem, Boolean)+0xa9 at C:\buildslave\unity\build\Editor\Mono\GUI\TreeView\TreeView.cs:267 C#
Void UnityEditor.TreeView:OnGUI (Rect, Int32)+0x23b at C:\buildslave\unity\build\Editor\Mono\GUI\TreeView\TreeView.cs:434 C#
Void UnityEditor.ProjectBrowser:OnGUI ()+0x1a2 at C:\buildslave\unity\build\Editor\Mono\ProjectBrowser.cs:1733 C#
Object System.Reflection.MonoMethod:Invoke (Object, BindingFlags, Binder, Object[], CultureInfo)+0xd6 at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222 C#
Object System.Reflection.MethodBase:Invoke (Object, Object[])+0x6 at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115 C#
Void UnityEditor.HostView:Invoke (String, Object)+0x12 at C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:244 C#
Void UnityEditor.HostView:Invoke (String)+0x8 at C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:237 C#
Void UnityEditor.DockArea:OnGUI ()+0x508 at C:\buildslave\unity\build\Editor\Mono\GUI\DockArea.cs:681 C#

Thanks'.

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #653 by Frank
Replied by Frank on topic Issue in ResourceManager
Hi,
From your call stack it seems you get that error because you are calling ScriptLocalization.Get from the Awake function of the Filters class.

The plugin needs to create or reference a ResourceManager when accessing the Translations. That's why you shouldn't access it on any Awake function.

A quick fix is to move those calls into the Start method. That way, Unity will be able to look for the resource manager.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

Time to create page: 0.238 seconds
Template by JoomlaShine