Esempio n. 1
0
        // 转换UI坐标系下的平面节点
        public DuMixNodeUIPlane ConvertUIPlane(DuMixCMPTUIObject item)
        {
            var canvasSize = new Vector2(720, 1280);
            // TODO: Handle Rotation
            var nodeName = item.gameObject.name;
            var position = CoordinateUtil.ConvertUIPosition(item.gameObject.transform.localPosition, canvasSize);
            var scale    = CoordinateUtil.ConvertUIScale(item.gameObject.transform.localScale, canvasSize);
            // json part
            var duMixNode = new DuMixNodeUIPlane();

            duMixNode.name = nodeName;
            duMixNode.material.common.textureList[0].textureName = "res/" + item.resPath;
            duMixNode.hudDisplay.marginTop  = position.y;
            duMixNode.hudDisplay.marginLeft = position.x;
            duMixNode.hudDisplay.screenRatio.screenWidthRatio  = scale.x;
            duMixNode.hudDisplay.screenRatio.screenHeightRatio = scale.y;
            // resource part
            var srcPath = DuMixGlobalStringDefs.ResourcePath() + item.resPath;
            var desPath = DuMixGlobalStringDefs.BuildPath() + "ar/res/" + item.resPath;

            if (File.Exists(desPath))
            {
                File.Delete(desPath);
            }
            var desDirPath = Path.GetDirectoryName(desPath);

            Debug.Log(desDirPath);
            if (!Directory.Exists(desDirPath))      // create directory
            {
                Directory.CreateDirectory(desDirPath);
            }

            FileUtil.CopyFileOrDirectory(srcPath, desPath);
            return(duMixNode);
        }
Esempio n. 2
0
        public override void UpdateDuMixScreenLayout()
        {
            var position = CoordinateUtil.ConvertUIPosition(this.gameObject.transform.localPosition,
                                                            new Vector2(720, 1280));
            var scale = CoordinateUtil.ConvertUIScale(this.gameObject.transform.localScale,
                                                      new Vector2(720, 1280));

            hudData.marginTop         = position.y;
            hudData.marginLeft        = position.x;
            hudData.screenWidthRatio  = scale.x;
            hudData.screenHeightRatio = scale.y;
        }
Esempio n. 3
0
        // 转换UI坐标系下的视频节点
        public DuMixNodeUIVideo ConvertUIVideo(DuMixCMPTUIVideo item)
        {
            var canvasSize = new Vector2(720, 1280);
            // TODO: Handle Rotation
            var nodeName = item.gameObject.name;
            var position = CoordinateUtil.ConvertUIPosition(item.gameObject.transform.localPosition, canvasSize);
            var scale    = CoordinateUtil.ConvertUIScale(item.gameObject.transform.localScale, canvasSize);
            // json part
            var duMixNode = new DuMixNodeUIVideo();

            duMixNode.name = nodeName;
            duMixNode.material.common.uvUnwrapedTextureName  = "res/" + item.resPath;
            duMixNode.material.android.uvUnwrapedTextureName = "res/" + item.resPath;
            if (item.videoType == DuMixCMPTUIVideo.VideoType.commonVideo)
            {
                duMixNode.material.common.defaultShaderName  = "ordinaryVideoShader";
                duMixNode.material.android.defaultShaderName = "androidOrdinaryVideoShader";
            }
            duMixNode.hudDisplay.marginTop  = position.y;
            duMixNode.hudDisplay.marginLeft = position.x;
            duMixNode.hudDisplay.screenRatio.screenWidthRatio  = scale.x;
            duMixNode.hudDisplay.screenRatio.screenHeightRatio = scale.y;
            duMixNode.rotation = "90,0,0";
            //// resource part
            var srcPath = DuMixGlobalStringDefs.ResourcePath() + item.resPath;
            var desPath = DuMixGlobalStringDefs.BuildPath() + "ar/res/" + item.resPath;

            if (File.Exists(desPath))
            {
                File.Delete(desPath);
            }
            var desDirPath = Path.GetDirectoryName(desPath);

            Debug.Log(desDirPath);
            if (!Directory.Exists(desDirPath))
            {    // create directory
                Directory.CreateDirectory(desDirPath);
            }

            FileUtil.CopyFileOrDirectory(srcPath, desPath);
            return(duMixNode);
        }