Exemple #1
0
        public override void readFields(BmobInput input)
        {
            base.readFields(input);

            pos_x   = input.getDouble("pos_x");
            pos_y   = input.getDouble("pos_y");
            pos_z   = input.getDouble("pos_z");
            rot_w   = input.getDouble("rot_w");
            rot_x   = input.getDouble("rot_x");
            rot_y   = input.getDouble("rot_y");
            rot_z   = input.getDouble("rot_z");
            scale_x = input.getDouble("scale_x");
            scale_y = input.getDouble("scale_y");
            scale_z = input.getDouble("scale_z");

            type    = input.getInt("type");
            text    = input.getString("text");
            texture = input.getFile("texture");
            video   = input.getFile("video");

            model = input.Get <BmobPointer <BmobModel> >("model");
            mark  = input.Get <BmobPointer <Mark> >("mark");

            version = input.getInt("version");
        }
Exemple #2
0
        public static IEnumerator getMetaFile(BmobFile metaFile, Action <List <GameObject> > after)
        {
            MapMeta meta = null;

            yield return(TapOnUtils.downloadFile(
                             metaFile.url,
                             wr =>
            {
                meta = JsonUtility.FromJson <MapMeta>(wr.downloadHandler.text);
            }));

            List <GameObject>  objects = new List <GameObject>();
            List <IEnumerator> tasks   = new List <IEnumerator>();

            foreach (MapMeta.PropInfo propInfo in meta.Props)
            {
                if (propInfo.type == MapMeta.PropType.Text)
                {
                    GameObject instance = GameObject.Instantiate(Globals.instance.templetes[0]);
                    instance.tag = "word";
                    instance.SetActive(false);
                    TextMesh tm = instance.GetComponentInChildren <TextMesh>();
                    tm.text = propInfo.text;
                    instance.transform.position   = new Vector3(propInfo.Position[0], propInfo.Position[1], propInfo.Position[2]);
                    instance.transform.rotation   = new Quaternion(propInfo.Rotation[0], propInfo.Rotation[1], propInfo.Rotation[2], propInfo.Rotation[3]);
                    instance.transform.localScale = new Vector3(propInfo.Scale[0], propInfo.Scale[1], propInfo.Scale[2]);
                    objects.Add(instance);
                }
                if (propInfo.type == MapMeta.PropType.Texture)
                {
                    GameObject instance = GameObject.Instantiate(Globals.instance.templetes[1]);
                    instance.tag = "texture";
                    instance.SetActive(false);
                    Renderer rd = instance.GetComponentInChildren <Renderer>();
                    instance.transform.position   = new Vector3(propInfo.Position[0], propInfo.Position[1], propInfo.Position[2]);
                    instance.transform.rotation   = new Quaternion(propInfo.Rotation[0], propInfo.Rotation[1], propInfo.Rotation[2], propInfo.Rotation[3]);
                    instance.transform.localScale = new Vector3(propInfo.Scale[0], propInfo.Scale[1], propInfo.Scale[2]);
                    objects.Add(instance);

                    IEnumerator downloadTexture = TapOnUtils.downloadFile(
                        propInfo.infoUrl,
                        wr_dt =>
                    {
                        Texture2D texture = new Texture2D(10, 10);
                        texture.LoadImage(wr_dt.downloadHandler.data);
                        rd.material.mainTexture = texture;
                    });
                    tasks.Add(downloadTexture);
                }
            }
            foreach (IEnumerator t in tasks)
            {
                yield return(t);
            }
            if (after != null)
            {
                after(objects);
            }
        }
Exemple #3
0
        public override void readFields(BmobInput input)
        {
            base.readFields(input);

            modelType = input.getInt("modelType");
            modelName = input.getString("modelName");
            preview   = input.getFile("preview");
            asset     = input.getFile("assetAndroid");
        }
Exemple #4
0
        public override void readFields(BmobInput input)
        {
            base.readFields(input);

            coordinate = input.getGeoPoint("position");
            type       = input.getInt("type");
            userId     = input.getString("userId");
            upLoadTime = input.getString("createdAt");
            snapShot   = input.getFile("snapShot");
        }
Exemple #5
0
        // async方式异步请求处理,非阻塞访问
        private async void uploadBtn_Click(object sender, EventArgs e)
        {
            formstatus.Text = "正在上传...";

            var Result = await Bmob.FileUploadTaskAsync(fileText.Text);

            FinishedCallback(Result, resultText);

            bmobFile = Result;

            enterDba.Enabled = true;
            formstatus.Text  = "上传成功!";
        }
Exemple #6
0
        public override void readFields(BmobInput input)
        {
            base.readFields(input);


            MapId      = input.getString("mapID");
            MapName    = input.getString("mapName");
            coordinate = input.getGeoPoint("position");
            //userId = input.getString("userId");
            upLoadTime = input.getString("createdAt");
            snapShot   = input.getFile("snapShot");
            metaFile   = input.getFile("metaFile");
            //meta = input.getFile("meta");
        }
Exemple #7
0
 public Task <EmptyCallbackData> FileDeleteTaskAsync(BmobFile file)
 {
     return(ExecuteTaskAsync <EmptyCallbackData>(callback => { FileDelete(file, callback); }, CancellationToken.None));
 }
        public IEnumerator SaveMapMeta()
        {
            //if (mapData == null)
            //{
            //    return;
            //}

            Debug.Log("length: " + mapData.Props.Count);

            var propInfos = new List <MapMeta.PropInfo>();

            foreach (var prop in mapData.Props)
            {
                var position = prop.transform.localPosition;
                var rotation = prop.transform.localRotation;
                var scale    = prop.transform.localScale;
                MapMeta.PropType typeTemp;
                string           textTemp = null;
                BmobFile         infoTemp = null;

                Debug.Log("prop tag: " + prop.tag);
                Debug.Log("prop name: " + prop.name);

                if ("word" == prop.tag)
                {
                    typeTemp = MapMeta.PropType.Text;
                    textTemp = prop.GetComponentInChildren <TextMesh>().text;
                    propInfos.Add(new MapMeta.PropInfo()
                    {
                        Name     = prop.name,
                        Position = new float[3] {
                            position.x, position.y, position.z
                        },
                        Rotation = new float[4] {
                            rotation.x, rotation.y, rotation.z, rotation.w
                        },
                        Scale = new float[3] {
                            scale.x, scale.y, scale.z
                        },
                        type = typeTemp,
                        text = textTemp,
                    });
                }
                else
                {
                    byte[] info_byte = null;
                    if ("texture" == prop.tag)
                    {
                        typeTemp = MapMeta.PropType.Texture;
                        Texture rt = prop.GetComponentInChildren <MeshRenderer>().material.mainTexture;
                        if (rt == null)
                        {
                            Debug.LogError("RenderTexture is error");
                        }
                        else
                        {
                            RenderTexture destTexture = new RenderTexture(rt.width, rt.height, 0);
                            Graphics.Blit(rt, destTexture);
                            RenderTexture.active = destTexture;
                            var imgTemp = new Texture2D(rt.width, rt.height, TextureFormat.RGB24, false);
                            imgTemp.ReadPixels(new UnityEngine.Rect(0, 0, rt.width, rt.height), 0, 0);
                            imgTemp.Apply();
                            RenderTexture.active = null;
                            Destroy(destTexture);

                            info_byte = imgTemp.EncodeToJPG();
                            if (info_byte == null)
                            {
                                Debug.Log("info_byte is null");
                            }
                        }
                        //info_byte = prop.GetComponentInChildren<MeshRenderer>().material.mainTexture.
                        coroutines.Add(
                            Window.instance.startCoroutine(
                                TapOnUtils.upLoadFile(
                                    "NameCard_" + (tempInfoCount++) + "_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".jpg",
                                    "application/x-jpg",
                                    info_byte,
                                    (wr) =>
                        {
                            Restful_FileUpLoadCallBack t = TapOnUtils.fileUpLoadCallBackfromJson(wr.downloadHandler.text);
                            infoTemp = new BmobFile {
                                filename = t.filename, url = t.url
                            };
                            Debug.Log("NameCard save");
                            propInfos.Add(new MapMeta.PropInfo()
                            {
                                Name     = prop.name,
                                Position = new float[3] {
                                    position.x, position.y, position.z
                                },
                                Rotation = new float[4] {
                                    rotation.x, rotation.y, rotation.z, rotation.w
                                },
                                Scale = new float[3] {
                                    scale.x, scale.y, scale.z
                                },
                                type         = typeTemp,
                                infoFileName = infoTemp.filename,
                                infoUrl      = infoTemp.url,
                            });
                        })
                                ));
                    }
                    else if ("Video(Clone)" == prop.name)
                    {
                        typeTemp = MapMeta.PropType.Video;
                        // info_byte
                    }
                    else if ("Model(Clone)" == prop.name)
                    {
                        typeTemp = MapMeta.PropType.Model;
                        // info_byte
                    }
                    else
                    {
                        typeTemp = MapMeta.PropType.other;
                    }
                }
            }
            foreach (var cor in coroutines)
            {
                yield return(cor);
            }
            mapData.Meta.Props = propInfos;
            // 保存到本地
            MapMetaManager.Save(mapData.Meta);
        }
Exemple #9
0
 public void FileDelete(BmobFile file, BmobCallback <EmptyCallbackData> callback)
 {
     this.FileDelete(file.url, callback);
 }
        /// <summary>
        /// 初始化事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInit_Click(object sender, EventArgs e)
        {
            BmobWindows Bmob = new BmobWindows();

            Bmob.initialize("38cd909fe640756176303b980453db55", "9e8a836ccfd013f87619b284a97de02c"); // 初始化Bmob客户端
            BmobDebug.Register(msg => { Debug.WriteLine(msg); });                                    // 用于调试输出请求参数

            BmobQuery query = new BmobQuery();

            //新建查询 查询Activityrecord表中所有的数据 按时间正向排序
            Bmob.Find <ReadFile>("Activityrecord", query, (resp, exception) =>
            {
                // 处理查询网络异常
                if (exception != null)
                {
                    return;
                }

                //对返回结果进行处理
                List <ReadFile> list = resp.results;
                foreach (var game in list)
                {
                    BmobFile record = game.record;
                    if (record != null)
                    {
                        if (File.Exists(record.filename))
                        {
                            Console.WriteLine("跳过:" + record.filename);
                        }
                        else
                        {
                            Console.WriteLine("下载:" + record.filename);
                            //调用HttpDownload进行非重复文件的下载,此处下载为同步下载 即一个下载完才会执行之后代码
                            HttpDownload(record.url, "./" + record.filename);
                        }
                    }
                }
                Console.WriteLine("开始写入");
                String[] files = Directory.GetFiles("./", "*.txt", SearchOption.AllDirectories);
                foreach (string f in files)
                {
                    if (File.Exists("db.txt"))
                    {
                        Console.WriteLine("it is existed");
                    }
                    else
                    {
                        FileStream fs = new FileStream("db.txt", FileMode.CreateNew);
                        fs.Close();
                    }
                    Console.WriteLine("查看" + f);
                    if (f.Contains("db.txt"))
                    {
                        continue;
                    }
                    string a = System.IO.File.ReadAllText(f);
                    string b = System.IO.File.ReadAllText("db.txt");
                    System.IO.File.WriteAllText("db.txt", a + "\r\n" + b);
                    File.Delete(f);
                }
                byte[] byData   = new byte[100];
                char[] charData = new char[1000];

                // 这里是Bmob的回调函数 也就是查询完之后执行下载了所有文件再执行此处的合并和InitChart
                // 所以需要将这个设置为False 否则会提示操作跨线程错误
                Control.CheckForIllegalCrossThreadCalls = false;
                InitChart();
                Read("db.txt");
            });
        }
Exemple #11
0
        /*public static IEnumerator getAllProps()
         * {
         *
         * }*/
        public static async void addMarktoServer(Mark mark)
        {
            CreateCallbackData callback_mark = await Bmob.CreateTaskAsync(Mark.table_name, mark);

            if (callback_mark == null || callback_mark.objectId == null || callback_mark.objectId.Length == 0)
            {
                Debug.LogError("BmobRrror: Mark hasn't upload!");
                return;
            }
            Globals.instance.uploading = false;
            ((Unity.UIWidgets.widgets.Element)Globals.instance.nowContext).markNeedsBuild();

            using (Unity.UIWidgets.widgets.WindowProvider.of(Globals.instance.nowContext).getScope())
            {
                Window.instance.startCoroutine(
                    TapOnUtils.WaitSomeTime(
                        time: 0.5f,
                        after: () =>
                {
                    Debug.Log("in back home!");
                    Globals.instance.returnHome(() => { Globals.instance.returnMap(); });
                })
                    );
                Window.instance.startCoroutine(
                    TapOnUtils.upLoadFile(
                        "img_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".jpg",
                        "application/x-jpg",
                        mark.snapShot_byte,
                        wr =>
                {
                    Restful_FileUpLoadCallBack t = TapOnUtils.fileUpLoadCallBackfromJson(wr.downloadHandler.text);
                    BmobFile bf = new BmobFile {
                        filename = t.filename, url = t.url, group = t.cdnname
                    };
                    Mark m = new Mark {
                        snapShot = bf
                    };
                    Bmob.Update(
                        Mark.table_name,
                        callback_mark.objectId,
                        m,
                        (resp, exception) =>
                    {
                        if (exception != null)
                        {
                            Debug.Log("修改失败, 失败原因为: " + exception.Message);
                            return;
                        }

                        Debug.Log("修改成功, @" + resp.updatedAt);
                    });
                }));
                Window.instance.startCoroutine(
                    TapOnUtils.upLoadFile(
                        "Props_" + DateTime.Now.ToString("yyyy-MM-,") + ".json",
                        "application/json",
                        mark.meta_byte,
                        wr =>
                {
                    Restful_FileUpLoadCallBack t = TapOnUtils.fileUpLoadCallBackfromJson(wr.downloadHandler.text);
                    BmobFile bf = new BmobFile {
                        filename = t.filename, url = t.url, group = t.cdnname
                    };
                    Mark m = new Mark {
                        metaFile = bf
                    };
                    Bmob.Update(
                        Mark.table_name,
                        callback_mark.objectId,
                        m,
                        (resp, exception) =>
                    {
                        if (exception != null)
                        {
                            Debug.Log("修改失败, 失败原因为: " + exception.Message);
                            return;
                        }

                        Debug.Log("修改成功, @" + resp.updatedAt);
                    });
                }));
            }
        }
 public override void readFields(BmobInput input)
 {
     base.readFields(input);
     //读取属性值
     this.record = input.getFile("record");
 }