Пример #1
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);
        }
Пример #2
0
        protected void handleGetNodeImage(Command command)
        {
            Logger.d("handleGetNodeImage +" + command.recvObj);
            int instance = int.Parse(command.recvObj);

            try
            {
                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 image = uiHelper.GetImage(gameObject);
                if (image == null)
                {
                    //command.status = ResponseStatus.COMPONENT_NOT_EXIST;
                    //command.sendObj = "Component Image/RawImage/SpriteRender " + instance + " is not exists";
                    command.sendObj = "No Component with image";
                    command.status  = ResponseStatus.NO_SUCH_RESOURCE;
                }
                else
                {
                    command.sendObj = image;
                }
            }
            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);
        }