Пример #1
0
    private void UnSaveShare()
    {
        if (schemeManifest.isUnUpLoaded == false)
        {
            Share();
            return;
        }

        if (string.IsNullOrEmpty(schemeManifest.templateId) == true)
        {
            Debug.LogWarning("本地方案不保存无法分享");
        }
        else
        {
            OriginalProjectData originalProjectData = jsonCacheManager.GetCurrentOriginalProjectData();
            originalProjectData.id = schemeManifest.templateId;
            //101007 分享 title content photo HT5url collectTypr
            MsgToIOS msg = new MsgToIOS();
            msg.code                  = "101007";
            msg.info                  = new MsgToIOS.InfoToIOS();
            msg.info.shareType        = 0;
            msg.info.projectData      = originalProjectData;
            msg.info.projectData.meta = originalProjectData.meta;
            UnityIOSMsg.sendToIOS(msg);
        }
    }
Пример #2
0
    private void OnLoadedAllProduct(MyEvent obj)
    {
        Debug.Log("queueloader Complete");
        mainPageUIController.dispatchEvent(new LoadEvent(LoadEvent.CloseLoadingPage));

        QueueSimpleLoader   queueloader = obj.data as QueueSimpleLoader;
        OriginalProjectData data        = queueloader.bringData as OriginalProjectData;

        undoHelper.SetCurrentData(data);
    }
Пример #3
0
    public void ClearView()
    {
        OriginalProjectData projectData = new OriginalProjectData();

        projectData.data = new OriginalInputData();
        SetCurrentData(projectData, false);
        ResourcesPool.ClearPool();
        Resources.UnloadUnusedAssets();
        GC.Collect();
    }
Пример #4
0
    public void SetCurrentData(OriginalProjectData project, bool saveToLocal = true)
    {
        //SetToLocal(currentData);
        undoDatas.Clear();
        redoDatas.Clear();
        currentData                            = new TotalData();
        currentData.SaveId                     = 0;
        currentData.data                       = project.data;
        currentData.schemeManifest.id          = project.id;
        currentData.schemeManifest.templateId  = project.templateId;
        currentData.schemeManifest.meta        = project.meta;
        currentData.schemeManifest.name        = project.name;
        currentData.schemeManifest.description = project.description;
        currentData.schemeManifest.tempId      = project.tempId;
        currentData.schemeManifest.isNew       = project.isNew;
        currentData.schemeManifest.version     = project.version;

        currentData.schemeManifest.prices.Clear();
        currentData.schemeManifest.tempEffectMetas = project.tempEffectMetas;
        //是否为样板间
        currentData.schemeManifest.isTemplate = project.isTemplate;
        if (project.priceIdList != null)
        {
            currentData.schemeManifest.prices.AddRange(project.priceIdList);
            for (int i = 0; i < project.priceIdList.Count; i++)
            {
                string id = project.priceIdList[i];
                if (mainpageData.HasPriceData(id))
                {
                    continue;
                }
                int tempId;
                if (int.TryParse(id, out tempId))
                {
                    LoaderPool.CacheLoad(tempId, SimpleLoadDataType.JsonOffer, OnPriceLoaded);
                }
                else
                {
                    LoaderPool.CacheLoad(id, SimpleLoadDataType.JsonOffer, OnPriceLoaded);
                }
            }
        }

        //ClearView();
        RefreshView();
        if (saveToLocal == true)
        {
            jsonCacheManager.SaveSchemeToLocal();
        }

        schemeControl.dispatchEvent(new SchemeEvent(SchemeEvent.ChangeScheme));
        Resources.UnloadUnusedAssets();
    }
Пример #5
0
    public void SaveSchemeToLocal()
    {
        //if (Application.platform != RuntimePlatform.IPhonePlayer)
        //{
        //    Debug.Log("SaveToLocal");
        //    return;
        //}
        //Debug.Log("SaveToLocal");
        OriginalProjectData OriginalProjectData = GetCurrentOriginalProjectData();

        AddSchemeCache(OriginalProjectData);
    }
Пример #6
0
    private void Share()
    {
        OriginalProjectData originalProjectData = jsonCacheManager.GetCurrentOriginalProjectData();
        //101007 分享 title content photo HT5url collectTypr
        MsgToIOS msg = new MsgToIOS();

        msg.code                  = "101007";
        msg.info                  = new MsgToIOS.InfoToIOS();
        msg.info.shareType        = 0;
        msg.info.projectData      = originalProjectData;
        msg.info.projectData.meta = originalProjectData.meta;
        UnityIOSMsg.sendToIOS(msg);
    }
Пример #7
0
 public void AddSchemeCache(OriginalProjectData data, string json = null)
 {
     if (string.IsNullOrEmpty(json))
     {
         json = MyJsonTool.ToJson(data);
     }
     if (data.isUnUpload == true)
     {
         cacheLocalSchemeManager.AddSchemeCache(data.tempId, json);
         //Debug.Log("data.isUnUpload == true");
     }
     else
     {
         cacheServerSchemeManager.AddSchemeCache(data.id, json);
         //Debug.Log("data.isUnUpload == false");
     }
 }
Пример #8
0
    public override void enter()
    {
        base.enter();
        if (undoHelper.currentData.SaveId != 0)
        {
            //请先上传方案
            Debug.LogWarning("分享 是否保存方案");
            MessageBox.Instance.ShowOkCancelClose("分享方案", "是否保存方案", UnSaveShare, SaveSchemeToShare);
        }
        else if (schemeManifest.isUnUpLoaded == true)
        {
            if (string.IsNullOrEmpty(schemeManifest.templateId) == true)
            {
                //请先上传方案
                Debug.LogWarning("分享 是否保存方案");
                MessageBox.Instance.ShowOkCancelClose("分享方案", "请先上传方案", null, SaveSchemeToShare);
            }
            else
            {
                OriginalProjectData originalProjectData = jsonCacheManager.GetCurrentOriginalProjectData();
                originalProjectData.id = schemeManifest.templateId;
                //101007 分享 title content photo HT5url collectTypr
                MsgToIOS msg = new MsgToIOS();
                msg.code                  = "101007";
                msg.info                  = new MsgToIOS.InfoToIOS();
                msg.info.shareType        = 0;
                msg.info.projectData      = originalProjectData;
                msg.info.projectData.meta = originalProjectData.meta;
                UnityIOSMsg.sendToIOS(msg);
            }
        }
        else
        {
            Share();
        }

        if (inputMachine.currentInputIs2D)
        {
            inputMachine.setState(FreeState2D.NAME);
        }
        else
        {
            inputMachine.setState(FreeState3D.NAME);
        }
    }
Пример #9
0
    public OriginalProjectData GetCurrentOriginalProjectData()
    {
        originalInputData.BeforetSerializeFieldDo();
        OriginalProjectData originalProjectData = new OriginalProjectData();

        originalProjectData.data        = originalInputData;
        originalProjectData.id          = undoHelper.currentData.schemeManifest.id;
        originalProjectData.tempId      = undoHelper.currentData.schemeManifest.tempId;
        originalProjectData.name        = undoHelper.currentData.schemeManifest.name;
        originalProjectData.description = undoHelper.currentData.schemeManifest.description;
        originalProjectData.meta        = undoHelper.currentData.schemeManifest.meta;
        originalProjectData.isNew       = undoHelper.currentData.schemeManifest.isNew;
        originalProjectData.version     = undoHelper.currentData.schemeManifest.version;

        originalProjectData.priceIdList = new List <string>();
        originalProjectData.priceIdList.AddRange(undoHelper.currentData.schemeManifest.prices);
        return(originalProjectData);
    }
Пример #10
0
    private void OnLoadedAllProductCache(MyEvent obj)
    {
        Debug.Log("queueloader Complete");
        mainPageUIController.dispatchEvent(new LoadEvent(LoadEvent.CloseLoadingPage));

        QueueSimpleLoader queueloader = obj.data as QueueSimpleLoader;

        object[]            objs      = queueloader.bringData as object[];
        string              enterType = objs[0].ToString();
        OriginalProjectData data      = objs[1] as OriginalProjectData;

        switch (enterType)
        {
        case "4":
        case "5":
            undoHelper.SetCurrentData(data);
            break;

        default:
            undoHelper.SetCurrentData(data, false);
            break;
        }
    }
Пример #11
0
    public void CreatNewEnter()
    {
        OriginalProjectData OriginalProjectData = new OriginalProjectData();
        TotalData           total = new TotalData();

        OriginalProjectData.data        = total.data;
        OriginalProjectData.id          = total.schemeManifest.id;
        OriginalProjectData.name        = total.schemeManifest.name;
        OriginalProjectData.description = total.schemeManifest.description;
        OriginalProjectData.meta        = total.schemeManifest.meta;
        //OriginalProjectData.tempId = total.schemeManifest.tempId;
        OriginalProjectData.isNew = true;
        SetCurrentData(OriginalProjectData, false);
        if (cacheLocalSchemeManager.isReady)
        {
            currentData.schemeManifest.tempId = cacheLocalSchemeManager.GetNewLocalcacheTempId();
        }
        else
        {
            currentData.schemeManifest.tempId = -1;
            cacheLocalSchemeManager.addEventListener(MyCacheEvent.loadReady, LoadReady);
        }
        //jsonCacheManager.SaveSchemeToLocal();
    }
Пример #12
0
    private void onloaded(object obj)
    {
        SimpleOutterLoader loader = obj as SimpleOutterLoader;

        if (loader.state == SimpleLoadedState.Failed)
        {
            //Debug.LogError(loader.uri);
            return;
        }
        string json     = loader.loadedData.ToString();
        object jsonData = MyJsonTool.FromJson(json);

        MsgFromIOS.InfoFromIOS info = loader.bringData as MsgFromIOS.InfoFromIOS;

        OriginalProjectData         data = new OriginalProjectData();
        Dictionary <string, object> dic  = jsonData as Dictionary <string, object>;

        ///在线端数据
        if (dic.ContainsKey("products"))
        {
            //data.DeSerialize(dic);
        }
        ///移动端新数据
        else if (dic.ContainsKey("version"))
        {
            data.DeSerialize(dic);
        }
        ///移动端旧数据 或 错误数据
        else
        {
            data.DeSerialize(dic);
        }

        switch (info.enterType)
        {
        case "4":
        case "5":
            data.isTemplate = true;
            data.isNew      = true;
            data.templateId = info.projectId;
            data.id         = "";
            data.tempId     = jsonCacheManager.GetNewSchemeTempId();
            break;

        default:
            data.id     = info.projectId;
            data.tempId = info.tempId;
            data.isNew  = false;
            break;
        }
        //data.templateId = info.templateId;
        data.tempEffectMetas.Clear();
        List <object> matelist = info.msg as List <object>;

        for (int i = 0; i < matelist.Count; i++)
        {
            data.tempEffectMetas.Add(matelist[i].ToString());
        }

        //放到队列加载后
        //undoHelper.SetCurrentData(data);

        switch (info.enterType)
        {
        case "3":
        case "5":
            mainpageMachine.setState(ToThreeDState.Name);
            break;

        default:
            mainpageMachine.setState(ToTwoDState.Name);
            break;
        }

        float minX = 0;
        float maxX = 0;
        float minY = 0;
        float maxY = 0;

        for (int i = 0; i < data.data.pointList.Count; i++)
        {
            Vector2 v2 = data.data.pointList[i].pos;
            if (v2.x < minX)
            {
                minX = v2.x;
            }
            if (v2.x > maxX)
            {
                maxX = v2.x;
            }
            if (v2.y < minY)
            {
                minY = v2.y;
            }
            if (v2.y > maxY)
            {
                maxY = v2.y;
            }
        }
        Vector2 pos = Vector2.zero;

        pos.x = (minX + maxX) / 2;
        pos.y = (minY + maxY) / 2;
        CameraControler.Instance.ResetAllCamera(pos);

        QueueSimpleLoader queueloader = new QueueSimpleLoader(data);

        for (int i = 0; i < data.data.productList.Count; i++)
        {
            Product product = data.data.productList[i];
            if (product.assetBundlePath.IndexOf("http://") == -1)
            {
                continue;                                                  //if (string.IsNullOrEmpty(product.model3d)) continue;
            }
            SimpleOutterLoader outLoader = LoaderPool.WaitOutterLoad(product.assetBundlePath, SimpleLoadDataType.prefabAssetBundle, null, product, onloadedBforClone);
            queueloader.AddQueueItem(outLoader);
        }
        if (queueloader.getCount != 0)
        {
            queueloader.addEventListener(LoadEvent.QueueProgress, OnAllProductProgress);
            queueloader.addEventListener(LoadEvent.QueueComplete, OnLoadedAllProduct);
        }
        else
        {
            undoHelper.SetCurrentData(data);
        }
    }
Пример #13
0
    //private void SaveOffer()
    //{
    //    TestPrice price = new TestPrice();
    //    price.prices = undoHelper.currentData.schemeManifest.prices;
    //    string json = MyJsonTool.ToJson(price);
    //    WriteToLocal(Application.dataPath + "/offer.json", json);
    //}

    private IEnumerator Func(object[] arg1)
    {
        yield return(new WaitForEndOfFrame());

        OriginalProjectData data = new OriginalProjectData();

        //Camera camera3D = prefabs.mainCamera;
        //if (inputMachine.currentInputIs2D)
        //{
        //    view3D.RefreshView();
        //    prefabs.helpCamera.gameObject.SetActive(true);
        //    camera3D = prefabs.helpCamera;
        //}
        TouchCaptureScreen.Instance.AoutCaptureScreenImage();

        yield return(new WaitForSeconds(0.01f));

        yield return(new WaitForEndOfFrame());

        yield return(new WaitForSeconds(0.01f));

        yield return(new WaitForEndOfFrame());

        Texture2D texture = TouchCaptureScreen.Instance.texture; //CaptureScreen.Instance.CaptureCamera(camera3D);

        //mainpage.image.texture = texture;

        string textureEncoding = "";

        if (texture != null)
        {
            byte[] bytes = texture.EncodeToJPG();
            GameObject.DestroyImmediate(texture, true);
            texture = null;
            Resources.UnloadUnusedAssets();
            if (inputMachine.currentInputIs2D)
            {
                //prefabs.helpCamera.gameObject.SetActive(false);
            }
            textureEncoding = System.Convert.ToBase64String(bytes,
                                                            0,
                                                            bytes.Length,
                                                            Base64FormattingOptions.None
                                                            );

            Debug.LogWarning("截屏成功");
        }
        else
        {
            Debug.LogWarning("截屏失败");
        }
        //if (Application.platform == RuntimePlatform.WindowsEditor)
        //{
        //    Debug.Log(textureEncoding);
        //    WriteToLocal(Application.dataPath + "/OriginalProjectJson/textureEncoding/texture.txt", textureEncoding);
        //}
        schemeManifest.meta = data.meta = "data:image/jpeg;base64," + textureEncoding;
        originalInputData.BeforetSerializeFieldDo();
        data.data = originalInputData;
        //SchemeManifest schemeManifest = schemePageControl.schemeManifest;
        data.name        = schemeManifest.name;
        data.description = schemeManifest.description;
        data.isNew       = schemeManifest.isNew;
        data.id          = schemeManifest.id;
        data.tempId      = schemeManifest.tempId;
        data.priceIdList = schemeManifest.prices;
        data.version     = schemeManifest.version;

        string json = MyJsonTool.ToJson(data);

        jsonCacheManager.AddSchemeCache(data, json);

        MsgToIOS msg = new MsgToIOS();

        msg.code = "101004";
        MsgToIOS.InfoToIOS info = new MsgToIOS.InfoToIOS();
        info.projectData = data;
        info.type        = data.isNew == true ? 0 : 1;
        msg.info         = info;
        if (info.type == 0)
        {
            UnityIOSMsg.sendToIOS(msg, IOSEvent.SetSchemeId, CreatScheme);
        }
        else
        {
            UnityIOSMsg.sendToIOS(msg);
            controller.dispatchEvent(new MyEvent(MySaveSchemeToShare.SaveSchemeToShare));
        }

        setState(MainPageFreeState.Name);
        undoHelper.ResetSaveId();
    }