Exception when adding Language dynamically

More
5 years 2 months ago #3525 by protostarDean
I am creating and adding a language source data at runtime (The strings are downloaded from the web).

In the latest update (2.8.11) I get an exception here:
public void AddLanguage( string LanguageName, string LanguageCode )
		{
			if (GetLanguageIndex(LanguageName, false)>=0)
				return;

			LanguageData Lang = new LanguageData();
				Lang.Name = LanguageName;
				Lang.Code = LanguageCode;
			mLanguages.Add (Lang);

			int NewSize = mLanguages.Count;
			for (int i=0, imax=mTerms.Count; i<imax; ++i)
			{
				Array.Resize(ref mTerms[i].Languages, NewSize);
				Array.Resize(ref mTerms[i].Flags, NewSize);
			}
			#if UNITY_EDITOR
//!!!! ownerObject is null, causing an exception. !!!
				UnityEditor.EditorUtility.SetDirty(this.ownerObject);   

			#endif
		}
}

Works if there is a guard there, but be great if this was fixed.
Thanks!

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

More
5 years 2 months ago #3526 by Frank
Hi,
The LanguageSourceData was always meant to be used within a LanguageSourceAsset or a LanguageSource. But I guess its a valid usage to create that object dynamically and use it directly.

Will made the changes to support it.

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.

More
5 years 2 months ago #3530 by protostarDean
Awesome! Thanks for that.
I will look out for it in the next update.

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

More
5 years 1 month ago #3539 by Frank
I just uploaded v2.8.12b1 to the beta folder that includes a fix for that.
Now all SetDirty calls are safeguarded and you should be able to dynamically create a LanguageSourceData and use it at runtime without having that crash.

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.195 seconds
Template by JoomlaShine