Example #1
0
        /// <summary>
        /// 从资源中生成仪器
        /// </summary>
        /// <returns>The equipment.</returns>
        /// <param name="item">Item.</param>
        /// <param name="ItemPath">Item path.</param>
        public GameObject GenerateEquipment(KGUI_BackpackItem item, string ItemPath)
        {
            var itemObject = Resources.Load <GameObject>(universalPath + ItemPath);

            var go = Instantiate(itemObject) as GameObject;

            return(go);
        }
        /// <summary>
        /// 抓取背包创建
        /// </summary>
        /// <param name="itemData"></param>
        /// <param name="handIndex"></param>
        /// <returns></returns>
        public GameObject CreatEquipment(KGUI_BackpackItem item, int handIndex)
        {
            KGUI_Backpack_ItemData itemData = item.dataConfig;

            var itemObject = Resources.Load <GameObject>(universalPath + itemData.ItemPath);

            var go = Instantiate(itemObject) as GameObject;

            go.transform.position = new Vector3(go.transform.position.x, go.transform.position.y, -16.3f);
            KGUI_BackPackMark mark = go.GetComponent <KGUI_BackPackMark>() ?? go.AddComponent <KGUI_BackPackMark>();

            if (mark != null)
            {
                //仪器背包创建调用
                mark.OnCreateForBag(item, itemData.Name, handIndex);
            }

            //KinectTransfer.SetObjectGrab(go, handIndex);
            MOperateManager.SetObjectGrab(go, itemData.zValue, handIndex);
            this._handIndex = handIndex;

            #region 注释

            //==========================

            //Vector3 screenDevice = KinectTransfer.GetScreenHandPos(handIndex);
            //Vector3 worldDevice =
            //==========================

            //go.transform.DOScale(Vector3.one * 15, 0.1f);
            //层改变成UI层,然后离开时,在转化为其他层

            //设置抓取信息,不管相机如何移动,抓取的物体始终在屏幕坐标中。
            //Vector3 position;

            ////屏幕坐标
            //Vector3 screenPoint = KinectTransfer.GetMCKinectPositionStatus(out position, handIndex);
            //screenPoint.z = itemData.zValue;

            //float z = /*KinectConfig.mainCamera*/Camera.main.ScreenToWorldPoint(screenPoint).z;

            //go.transform.position = new Vector3(go.transform.position.x, go.transform.position.y, 0.8f);
            //go.transform.position = new Vector3(go.transform.position.x, go.transform.position.y,0);

            #endregion

            SetObjectFrontUI(false);

            return(go);
        }
        /// <summary>
        /// 从背包创建时执行
        /// </summary>
        /// <param name="name"></param>
        /// <param name="handIdex"></param>
        public void OnCreateForBag(KGUI_BackpackItem item, string name, int handIdex)
        {
            TagName = name;
            OwnItem = item;

            FeaturesObjects = gameObject.GetComponentsInChildren <Features.FeaturesObjectController>();

            ObjectFrontUI = gameObject.GetComponent <KGUI_ObjectFrontUI>();

            if (CreateForBag != null)
            {
                CreateForBag(TagName, handIdex);
            }
        }
        /// <summary>
        /// 从资源中生成仪器
        /// </summary>
        /// <returns>The equipment.</returns>
        /// <param name="item">Item.</param>
        /// <param name="ItemPath">Item path.</param>
        public GameObject GenerateEquipment(KGUI_BackpackItem item, string ItemPath)
        {
            var itemObject = Resources.Load <GameObject>(universalPath + ItemPath);

            var go = Instantiate(itemObject) as GameObject;

            KGUI_BackPackMark mark = go.GetComponent <KGUI_BackPackMark>() ?? go.AddComponent <KGUI_BackPackMark>();

            if (mark != null)
            {
                //仪器背包创建调用
                mark.OnCreateForBag(item, item.dataConfig.Name, 0);
            }

            return(go);
        }
Example #5
0
        private void OnEnable()
        {
            item = serializedObject.targetObject as KGUI_BackpackItem;

            if (buttonType == null)
            {
                buttonType = new KGUIButtonTypeEditor();
            }
            if (buttonEvent == null)
            {
                buttonEvent = new KGUIButtonEventEditor();
            }


            buttonType.OnInstantiation(serializedObject);
            buttonEvent.OnInstantiation(serializedObject);
        }
        /// <summary>
        /// 抓取背包创建
        /// </summary>
        /// <param name="itemData"></param>
        /// <param name="handIndex"></param>
        /// <returns></returns>
        public GameObject CreatEquipment(KGUI_BackpackItem item, int handIndex)
        {
            KGUI_Backpack_ItemData itemData = item.dataConfig;

            var go = GenerateEquipment(item, itemData.ItemPath);

            go.transform.position = new Vector3(go.transform.position.x, go.transform.position.y, -16.3f);
            //KGUI_BackPackMark mark = go.GetComponent<KGUI_BackPackMark>() ?? go.AddComponent<KGUI_BackPackMark>();
            //if (mark != null)
            //{
            //    //仪器背包创建调用
            //    mark.OnCreateForBag(item, itemData.Name, handIndex);
            //}

            //KinectTransfer.SetObjectGrab(go, handIndex);
            MOperateManager.SetObjectGrab(go, handIndex, itemData.zValue);
            this._handIndex = handIndex;

            SetObjectFrontUI(false);

            return(go);
        }