protected void handleGetNodeText(Command command)
 {
     Logger.d("handleGetNodeText +" + command.recvObj);
     try
     {
         int        instance   = int.Parse(command.recvObj);
         GameObject gameObject = GameObjectManager.INSTANCE.FindGameObjectGlobal(instance);
         if (null == gameObject)
         {
             //返回无该gameobject
             command.status  = ResponseStatus.GAMEOBJ_NOT_EXIST;
             command.sendObj = "GameObject " + instance + " is not exists";
             return;
         }
         string text = uiHelper.GetText(gameObject);
         if (text == null)
         {
             command.sendObj = "No Component with text";
             command.status  = ResponseStatus.NO_SUCH_RESOURCE;
         }
         else
         {
             command.sendObj = text;
         }
     }
     catch (System.Exception ex)
     {
         Logger.w(ex.Message + " " + ex.StackTrace);
         command.status  = ResponseStatus.UN_KNOW_ERROR;
         command.sendObj = ex.Message + " " + ex.StackTrace;
     }
     CommandDispatcher.SendCommand(command);
 }
Exemple #2
0
        private static XmlElement Transform2XmlElement(Transform t, GameObject[] selectedObjs, XmlDocument doc)
        {
            NGUIHelper helper = new NGUIHelper();
            XmlElement elem   = doc.CreateElement("GameObject");

            elem.SetAttribute("name", t.gameObject.name);
            elem.SetAttribute("components", GetObjectType(t.gameObject));
            elem.SetAttribute("id", t.gameObject.GetInstanceID().ToString());

            //Logger.d("t.gameObject.name=" + t.gameObject.name.ToString() + ", t.gameObject.GetType()=" + t.gameObject.GetType().FullName.ToString());

            string str = helper.GetText(t.gameObject);

            if (str != null)
            {
                elem.SetAttribute("txt", str);
            }

            str = helper.GetImage(t.gameObject);

            if (str != null)
            {
                elem.SetAttribute("img", str);
            }

            bool result = helper.IsVisible(t.gameObject);

            if (!result)
            {
                elem.SetAttribute("visible", "false");
            }

            if (selectedObjs != null && IsSelected(t.gameObject, selectedObjs))
            {
                elem.SetAttribute("sel", "true");
            }

            for (int i = 0; i < t.childCount; ++i)
            {
                Transform transform = t.GetChild(i);

                if (transform.gameObject.activeInHierarchy)
                {
                    elem.AppendChild(Transform2XmlElement(transform, selectedObjs, doc));
                }
            }

            return(elem);
        }