コード例 #1
0
        public void SetWifiItemList(List <string> nameList, int connectedId)
        {
            for (int i = 0; i < nameList.Count; i++)
            {
                GameObject           obj  = PrefabUtils.CreateGameObjectToParent(wifiInfoContent, wifiInfoItemPrefab);
                LiveHoloLensWifiItem item = obj.GetComponent <LiveHoloLensWifiItem>();

                item.wifiName.text = nameList[i];
                if (i == connectedId)
                {
                    item.buttonConnect.gameObject.SetActive(false);
                    item.connected.gameObject.SetActive(true);
                }
                else
                {
                    item.buttonConnect.gameObject.SetActive(false);
                    item.connected.gameObject.SetActive(false);
                }

                int           deltaY = -wifiItemList.Count * 28;
                RectTransform trans  = item.transform as RectTransform;
                trans.anchoredPosition = new Vector2(0, deltaY);
                trans.sizeDelta        = new Vector2(0, 30);

                wifiItemList.Add(item);
            }

            RectTransform transContent = wifiInfoContent.transform as RectTransform;

            transContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, wifiItemList.Count * 28);
        }
コード例 #2
0
ファイル: StorageSample.cs プロジェクト: comblox/METoolkit
    /// <summary>
    /// 从磁盘上加载已经下载过的资源,并显示
    /// </summary>
    /// <param name="fileName"></param>
    private void LoadAssetFromFile(string fileName)
    {
        StorageAssetData data = StorageAssetManager.Instance.LoadAsset(fileName);

        if (data.bundle == null)
        {
            Debug.LogError("Load Bundle " + fileName + " failed!");
            cursor.isBusy = false;
            return;
        }

        try
        {
            GameObject prefab = data.bundle.LoadAsset <GameObject>(data.assetName);

            PrefabUtils.DestroyAllChild(currentSelectBooth.gameObject);

            GameObject obj = PrefabUtils.CreateGameObjectToParent(currentSelectBooth.gameObject, prefab);
        }
        catch (System.Exception e)
        {
            Debug.LogError("Exception! " + e);
        }

        cursor.isBusy = false;
    }
コード例 #3
0
        /// <summary>
        /// 以默认尺寸创建一个快列表面板
        /// </summary>
        /// <returns></returns>
        public BlockList CreateBlockList()
        {
            GameObject obj = PrefabUtils.CreateGameObjectToParent(gameObject, blockListPrefab);
            BlockList  ui  = obj.GetComponent <BlockList>();

            ui.Init();

            return(ui);
        }
コード例 #4
0
        public void ShowInfo(string s)
        {
            GameObject obj = PrefabUtils.CreateGameObjectToParent(InfoRoot.gameObject, infoPrefab);

            obj.SetActive(true);
            InfoText info = obj.GetComponent <InfoText>();

            info.SetText(s);
        }
コード例 #5
0
        /// <summary>
        /// 创建一个块列表面板
        /// </summary>
        /// <param name="uiSizeX"></param>
        /// <param name="uiSizeY"></param>
        /// <returns></returns>
        public BlockList CreateBlockList(int uiSizeX, int uiSizeY)
        {
            GameObject obj = PrefabUtils.CreateGameObjectToParent(gameObject, blockListPrefab);
            BlockList  ui  = obj.GetComponent <BlockList>();

            ui.CountX = uiSizeX;
            ui.CountY = uiSizeY;

            ui.Init();

            return(ui);
        }
コード例 #6
0
        ////////////////////////////////////////////
        #region 创建、删除、本地存储Anchor相关内容
        ////////////////////////////////////////////

        /// <summary>
        /// 将指定的物体设置为Anchor
        /// </summary>
        /// <param name="name"></param>
        /// <param name="obj"></param>
        public AnchorObjectInfo AddAnchorObject(string name, GameObject obj)
        {
            AnchorObjectInfo info = new AnchorObjectInfo();

            info.anchorName = name;
            info.rootTrans  = obj.transform;

            AnchorDefinition define = obj.GetComponent <AnchorDefinition>();

            if (define == null)
            {
                define            = obj.AddComponent <AnchorDefinition>();
                define.anchorName = name;
            }
            info.definition = define;

            // 创建mark物体
            GameObject markObj = PrefabUtils.CreateGameObjectToParent(anchorMarkRoot, markPrefab);
            AnchorMark mark    = markObj.GetComponent <AnchorMark>();

            mark.Init(name, info);
            mark.rootObjectTransform = obj.transform;

            // 创建指引箭头
            GameObject arrowObj = PrefabUtils.CreateGameObjectToParent(gameObject, arrowPrefab);

            info.arrowTrans = arrowObj.transform;
            arrowObj.SetActive(false);

            // 设置位置
            Vector3 originPos = obj.transform.position;

            markObj.transform.position = originPos;

            info.mark = mark;

            AddAnchor(info);

            //info.mark.followRoot = true;
            //info.FollowRootObject();

            //mark.gameObject.SetActive(false);

            anchorObjectList.Add(info);

            Debug.Log("Add anchor [" + name + "] to obj [" + obj.name + "]");

            return(info);
        }
コード例 #7
0
        /// <summary>
        /// 用数据创建一个面板
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool CreateMenu(BlockMenuData data)
        {
            if (menuDic.ContainsKey(data.name))
            {
                // 已经有重名Menu
                Debug.Log("已经存在同名Menu!");
                return(false);
            }

            GameObject obj = PrefabUtils.CreateGameObjectToParent(null, menuPrefab);

            obj.name = "Menu[" + data.name + "]";
            BlockMenu menu = obj.GetComponent <BlockMenu>();

            menuDic.Add(data.name, menu);

            menu.BuildMenu(data);

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// 在指定象限添加一个按钮
        /// </summary>
        /// <param name="button"></param>
        /// <param name="q"></param>
        public BlockButton CreateButton(BlockPanel panel, QUADRANT q, BlockButtonData buttonData)
        {
            GameObject  buttonObj = PrefabUtils.CreateGameObjectToParent(panel.gameObject, BlockButtonPrefab);
            BlockButton button    = buttonObj.GetComponent <BlockButton>();

            // 初始化按钮
            button.Init(this, panel, q, buttonData);

            panel.SetButton(button, q);

            // 汇总按钮点击回调
            //button.cbClick += this.OnClickButton;

            buttonObj.SetActive(false);

            // 所有button在menu中留记录,以便修改
            // 这里暂时不判断按钮重名了……原则上,按钮不允许重名,可以在编辑器层面保证
            buttonDic.Add(button.buttonId, button);

            return(button);
        }
コード例 #9
0
        public void Init()
        {
            Clear();

            for (int j = 0; j < CountY; j++)
            {
                for (int i = 0; i < CountX; i++)
                {
                    GameObject    obj  = PrefabUtils.CreateGameObjectToParent(grid, itemPrefab);
                    BlockListItem item = obj.GetComponent <BlockListItem>();
                    item.Init(this);

                    itemList.Add(item);

                    CalItemPos(item, i, j);
                }
            }

            countPerPage = CountX * CountY;

            prevReceiver.cbEnter = OnButtonEnter;
            prevReceiver.cbExit  = OnButtonExit;
            prevReceiver.cbTap   = OnTapPrev;

            nextReceiver.cbEnter = OnButtonEnter;
            nextReceiver.cbExit  = OnButtonExit;
            nextReceiver.cbTap   = OnTapNext;

            closeReceiver.cbEnter = OnButtonEnter;
            closeReceiver.cbExit  = OnButtonExit;
            closeReceiver.cbTap   = OnTapClose;

            loadingObj.SetActive(false);
            prevReceiver.gameObject.SetActive(false);
            nextReceiver.gameObject.SetActive(false);

            pageText.text = "";

            gameObject.SetActive(false);
        }
コード例 #10
0
ファイル: LiveController.cs プロジェクト: comblox/METoolkit
        protected override void _TurnOn()
        {
            // 加载Live配置文件
            AppConfig config = AppConfig.Instance;

            config.LoadConfig(MEHoloConstant.LiveConfigFile);
            listenPort    = int.Parse(AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Live_Port", "8099"));
            listenPortUDP = int.Parse(AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Live_Port_UDP", "8098"));
            useUDP        = bool.Parse(AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Use_UDP", "TRUE"));
            outputPath    = AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Out_Put_Path", "C:\\HologramCapture");

            config.LoadConfig(MEHoloConstant.CalibrationConfigFile);
            holoServerHost = config.GetConfigByFileName(MEHoloConstant.NetworkConfigFile, "Server_Host", "127.0.0.1");

            outputPath = config.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Out_Put_Path", "./");
            if (!outputPath.EndsWith("/") && !outputPath.EndsWith("\\"))
            {
                outputPath += "/";
            }

            // 读取参数设置
            if (!LiveParam.LoadParam())
            {
                LiveParam.SoundVolume = AudioListener.volume;
                LiveParam.SaveParam();
            }

            // 读取本地位置存储文件
            LoadTransformByFile();

            // 初始化并启动UI
            GameObject uiObj = PrefabUtils.CreateGameObjectToParent(this.gameObject, uiPrefab);

            liveUI = uiObj.GetComponent <LiveControllerUI>();
            liveUI.Init(this, (float)GetFrameWidth() / (float)GetFrameHeight());
            liveUI.TurnOn();

            // 初始化Windows device protocal
            wdpController.Init(this, liveUI);


            // 启动Lilve摄像机
            GameObject cameraObj = PrefabUtils.CreateGameObjectToParent(this.gameObject, holoCameraPrefab);

            holoCamera = cameraObj.GetComponent <HolographicCameraManager>();

            calibrationManager = holoCamera.gameObject.AddComponent <CalibrationManager>();
            calibrationManager.Init();

            // 延迟启动全息摄影机
            StartCoroutine(StartHoloCamera());

            // Log
            logManager = LogManager.Instance;

            // 关闭主摄影机的显示
            oldCameraMask = mainCamera.cullingMask;
            //mainCamera.cullingMask = 0;

            // 设置一下frameoffset
            SetFrameOffset(0.5f);

            // 停止input操作

            /*
             * if (inputManager != null)
             * {
             *  inputManager.StopCapture();
             * }
             */
        }
コード例 #11
0
        protected override void _TurnOn()
        {
            // 加载Live配置文件
            AppConfig config = AppConfig.Instance;

            config.LoadConfig(MEHoloConstant.LiveConfigFile);
            listenPort    = int.Parse(AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Live_Port", "8099"));
            listenPortUDP = int.Parse(AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Live_Port_UDP", "8098"));
            useUDP        = bool.Parse(AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Use_UDP", "TRUE"));
            outputPath    = AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Out_Put_Path", "C:\\HologramCapture");

            frameRate = int.Parse(AppConfig.Instance.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Frame_Rate", "60"));

            config.LoadConfig(MEHoloConstant.CalibrationConfigFile);
            holoServerHost = config.GetConfigByFileName(MEHoloConstant.NetworkConfigFile, "Server_Host", "127.0.0.1");
            int.TryParse(config.GetConfigByFileName(MEHoloConstant.NetworkConfigFile, "Server_Port", "8848"), out holoServerPort);

            outputPath = config.GetConfigByFileName(MEHoloConstant.LiveConfigFile, "Out_Put_Path", "./");
            if (!outputPath.EndsWith("/") && !outputPath.EndsWith("\\"))
            {
                outputPath += "/";
            }

            // 读取参数设置
            if (!LiveParam.LoadParam())
            {
                LiveParam.SoundVolume = AudioListener.volume;
                LiveParam.SaveParam();
            }



            // 读取本地位置存储文件
            LoadTransformByFile(LoadTransType.CameraAndAnchor);

            // 初始化并启动UI
            GameObject uiObj = PrefabUtils.CreateGameObjectToParent(this.gameObject, uiPrefab);

            liveUI = uiObj.GetComponent <LiveControllerUI>();
            liveUI.Init(this, (float)GetFrameWidth() / (float)GetFrameHeight());
            liveUI.TurnOn();

            // 初始化Windows device protocal
            wdpController.Init(this, liveUI);

            calibrationManager = holoCamera.gameObject.AddComponent <CalibrationManager>();
            calibrationManager.Init();

            // 刷新显示
            //  liveUI.mainPanel.RefreshFOVInput();

            // 延迟启动全息摄影机
            StartHoloCamera();

            // Log
            logManager = LogManager.Instance;

            // 关闭主摄影机的显示
            oldCameraMask = mainCamera.cullingMask;
            //mainCamera.cullingMask = 0;

            // 设置一下frameoffset
            SetFrameOffset(0f);

            // 停止input操作

            /*
             * if (inputManager != null)
             * {
             *  inputManager.StopCapture();
             * }
             */

            // 绑定Anchor回调
            anchorController.AddCallbackTurnOn(OnAnchorTurnOn);
            anchorController.AddCallbackTurnOff(OnAnchorTurnOff);
            StartCoroutine(WaitForSetAlpha());
            StartCoroutine(WaitForSetFilter());
        }