Author Topic: WP8 Build - Error on NGUITools script, UnityEditor not found  (Read 2632 times)

Antares88

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 35
    • View Profile
Fixed, look at the edit. Maybe the same fix should be applied to next NGUI update?

Hi,
I'm trying to build my project for WP8.
I'm using Unity 4.5 with NGUI 3.6.3.

When I go to build and it starts compiling the scripts, I get the following error:

Quote
Assets/NGUI/Scripts/Internal/NGUITools.cs(470,17): error CS0103: The name `UnityEditor' does not exist in the current context

This is the line triggering the error:

Quote
UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create Object");

I tried to add a "using UnityEditor;" on top of the script and I get the error again, this time on the line where I put the "using" instruction and asking if I'm missing an assembly reference.
I checked on my Assembly-CSharp/References and the UnityEditor.dll is there.

Any advice?

Edit:
I wrapped line 470 of NGUITools.cs with the platform dependent directive:
Quote
#IF UNITY_EDITOR
UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create Object");
#endif
and it stopped giving the error.

It seems that a built game cannot use the UnityEditor namespace.
« Last Edit: June 07, 2014, 04:41:38 PM by Antares88 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: WP8 Build - Error on NGUITools script, UnityEditor not found
« Reply #1 on: June 07, 2014, 09:29:14 PM »
Yup, thanks -- the #if UNITY_EDITOR section seems to be missing.