示例#1
0
        //加载3个角色空位中的人物形象
        public void OnLoadCharacters(CharacterInfo message, FUI holder, Controller controller, FUI money, FUI mail, FUI level, FUI location)
        {
            if (message.Level == 0)
            {
                controller.SetSelectedIndex(0);
            }
            else
            {
                controller.SetSelectedIndex(1);
                //获得资源设置
                string skeleton = SekiaHelper.GetSkeletonName(message.Skeleton);
                string weapon   = SekiaHelper.GetWeaponName(message.Weapon);
                string head     = SekiaHelper.GetHeadName(message.Head);
                string chest    = SekiaHelper.GetChestName(message.Chest);
                string hand     = SekiaHelper.GetHandName(message.Hand);
                string feet     = SekiaHelper.GetFeetName(message.Feet);

                //设置模型到指定位置
                GameObject demo = SekiaHelper.CreateCharacter(skeleton, weapon, head, chest, hand, feet);
                demo.transform.localPosition = new Vector3(30, -125, 1000);   //模型的原点在脚下 向下位移半个身高 向右位移1/4身宽
                //Log.Debug($"Holder位置 X:{holder.GObject.x}  Y:{holder.GObject.y}"); //编辑器中的坐标 以左上角为原点 Y为正值
                demo.transform.localScale       = new Vector3(125, 125, 125); //大小
                demo.transform.localEulerAngles = new Vector3(0, 180, 0);     //角度
                GoWrapper wrapper = new GoWrapper(demo);
                holder.GObject.asGraph.SetNativeObject(wrapper);

                //设置各项参数
                money.GObject.asTextField.text    = message.Money.ToString();
                mail.GObject.asTextField.text     = message.Mail.ToString();
                level.GObject.asTextField.text    = $"Lv.{message.Level} {message.Name}";
                location.GObject.asTextField.text = $"{Enum.GetName(message.Career.GetType(), message.Career)}·{Enum.GetName(message.Region.GetType(), message.Region)}";
            }
        }
 //检测角色名称是否合法
 public void OnCheckCreate()
 {
     if (this.isCreatingCharacter || this.IsDisposed)
     {
         return;
     }
     this.isCreatingCharacter = true;
     SekiaHelper.CreateNewCharacter(Seat, NameInput.Get("Input").GObject.asTextInput.text, Gender.selectedIndex, Career.selectedIndex).NoAwait();
 }
        //切换身体部分模型事件
        public void OnControllerChanged()
        {
            //默认设置
            string skeleton = "ch_pc_hou_ZhanShi";
            string weapon   = "ch_we_one_hou_004";
            string head     = "ch_pc_hou_004_tou";
            string chest    = "ch_pc_hou_004_shen";
            string hand     = "ch_pc_hou_004_shou";
            string feet     = "ch_pc_hou_004_jiao";

            //Demo被销毁 Weapon还在
            if (isCreateComplete)
            {
                UnityEngine.Object.Destroy(Wrapper.wrapTarget);
                UnityEngine.Object.Destroy(Demo);
            }
            int    genderindex = Gender.selectedIndex;
            string gender      = "";

            switch (genderindex)
            {
            case 0:     //男
                gender = "男";
                break;

            case 1:     //女
                gender = "女";
                head   = "ch_pc_hou_006_tou";
                chest  = "ch_pc_hou_006_shen";
                hand   = "ch_pc_hou_006_shou";
                feet   = "ch_pc_hou_006_jiao";
                break;

            default:
                break;
            }

            int careerindex = Career.selectedIndex;

            switch (careerindex)
            {
            case 0:     //战士
                Log.Debug(gender + "战士");
                break;

            case 1:     //法师
                Log.Debug(gender + "法师");
                skeleton = "ch_pc_hou_FaShi";
                weapon   = "ch_we_one_hou_006";
                break;

            default:
                break;
            }

            Demo = SekiaHelper.CreateCharacter(skeleton, weapon, head, chest, hand, feet);
            Demo.transform.localPosition    = new Vector3(30, -125, 1000); //位置
            Demo.transform.localScale       = new Vector3(125, 125, 125);  //大小
            Demo.transform.localEulerAngles = new Vector3(0, 180, 0);      //角度
            Wrapper = new GoWrapper(Demo);
            Holder.GObject.asGraph.SetNativeObject(Wrapper);

            //或者通过更新GoWrapper包装对象
            //参考:http://www.fairygui.com/guide/unity/insert3d.html
        }