Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Malzbier on August 09, 2012, 05:03:15 AM

Title: Force Update UILable with UILocalize in editor
Post by: Malzbier on August 09, 2012, 05:03:15 AM
I like to force update a(or multible) UILable with UILocalize in editor.

So i wrote a custom inspector for UILocalize:

  1. [CustomEditor(typeof(UILocalize))]
  2. public class UILocalizeInspector : Editor
  3. {
  4.        
  5.         UILocalize mUILocalize;
  6.         public override void OnInspectorGUI ()
  7.         {
  8.                 DrawDefaultInspector();
  9.                 EditorGUIUtility.LookLikeControls(80f);
  10.                 mUILocalize = target as UILocalize;
  11.                 if(GUILayout.Button("Localize!"))
  12.                 {
  13.                         mUILocalize.Localize();
  14.                         mUILocalize.gameObject.GetComponent<UILabel>().MarkAsChanged();
  15.                 }
  16.         }
  17. }

My problem is that the update process of UILabel sheems to call the UIRoot Scritp witch is Producing the following error in the editor around 10 times:


  1. !IsPlayingOrAllowExecuteInEditMode ()
  2. UnityEngine.Component:BroadcastMessage(String, Object, SendMessageOptions)
  3. UIRoot:Broadcast(String, Object) (at Assets/NGUI/Scripts/UI/UIRoot.cs:91)
  4. Localization:Load(TextAsset) (at Assets/NGUI/Scripts/Internal/Localization.cs:157)
  5. Localization:set_currentLanguage(String) (at Assets/NGUI/Scripts/Internal/Localization.cs:100)
  6. Localization:get_currentLanguage() (at Assets/NGUI/Scripts/Internal/Localization.cs:69)
  7. UILocalize:Localize() (at Assets/NGUI/Scripts/UI/UILocalize.cs:73)
  8. UILocalizeInspector:OnInspectorGUI() (at Assets/Scripts/GUI/Editor/UILocalizeInspector.cs:24)
  9. UnityEditor.DockArea:OnGUI()

Without:
  1.  mUILocalize.gameObject.GetComponent<UILabel>().MarkAsChanged();
there are no errors.
Title: Re: Force Update UILable with UILocalize in editor
Post by: ArenMook on August 09, 2012, 02:07:52 PM
Localization system is not marked as ExecuteInEditMode, so it won't work unless the application is playing. Same with UIRoot. The system is simply not designed to be executed in edit mode.