Exemplo n.º 1
0
    /// <summary>
    /// 携程-加载模型
    /// </summary>
    /// <param name="modelInfo"></param>
    /// <param name="userModelData"></param>
    /// <param name="action"></param>
    /// <returns></returns>
    public IEnumerator CoroutineForLoadModel(ModelInfoBean modelInfo, UserModelDataBean userModelData, Action action)
    {
        //读取模型
        ResourceRequest resourceRequest = Resources.LoadAsync("Model/" + modelInfo.model_name);

        yield return(resourceRequest);

        GameObject objModelTemp = resourceRequest.asset as GameObject;

        //移除场景中的模型
        CptUtil.RemoveChildsByActive(gameObject);
        //创建模型
        GameObject objModel = Instantiate(gameObject, objModelTemp);

        //初始化模型位置
        objModel.transform.position = Vector3.zero;
        //添加模型控件
        GameModelCpt gameModel = CptUtil.AddCpt <GameModelCpt>(objModel);

        gameModel.SetData(userModelData, modelInfo);
        //设置加载的模型
        currentLoadModel = gameModel;
        action?.Invoke();
        Resources.UnloadUnusedAssets();
    }
    public void OnCellForItem(ScrollGridCell itemCell)
    {
        ModelInfoBean          modelInfo = listModelData[itemCell.index];
        UIItemForBuleprintList itemCpt   = itemCell.GetComponent <UIItemForBuleprintList>();

        itemCpt.SetData(modelInfo);
    }
Exemplo n.º 3
0
    public void SetData(UserModelDataBean userModelData, ModelInfoBean modelInfo)
    {
        if (modelInfo == null)
        {
            return;
        }
        if (userModelData == null)
        {
            return;
        }
        dissolveAmountId = Shader.PropertyToID(m_DissolveAmount);
        mapMaterialForModel.Clear();
        Texture textureDisolveGuide = Resources.Load("Texture/noise_1") as Texture;

        if (!CheckUtil.ListIsNull(modelInfo.listPartData))
        {
            for (int i = 0; i < modelInfo.listPartData.Count; i++)
            {
                ModelPartInfoBean partInfo     = modelInfo.listPartData[i];
                Renderer          itemRenderer = CptUtil.GetCptInChildrenByName <Renderer>(gameObject, partInfo.part_name);
                //获取所有的Material
                List <Material> listMaterial = new List <Material>();
                itemRenderer.GetMaterials(listMaterial);
                //获取用户进度
                UserModelPartDataBean userModelPartData = userModelData.GetUserPartDataById(partInfo.id);
                float pro = 0;
                if (userModelPartData != null)
                {
                    pro = userModelPartData.GetProgress(partInfo.max_level);
                }
                //重新设置所有的shader
                foreach (Material itemMaterial in listMaterial)
                {
                    Texture itemTexture = itemMaterial.GetTexture("_MainTex");
                    if (itemTexture)
                    {
                        itemMaterial.shader = Shader.Find("ASESampleShaders/Community/DissolveBurnWithFire");
                        itemMaterial.SetTexture("_Albedo", itemTexture);
                        itemMaterial.SetTexture("_Normal", itemTexture);
                        itemMaterial.SetTexture("_BurnRamp", itemTexture);
                        itemMaterial.SetFloat("_MaskClipValue", 0.5f);
                    }
                    else
                    {
                        Color color = itemMaterial.GetColor("_Color");
                        itemMaterial.shader = Shader.Find("ASESampleShaders/Community/DissolveBurn_01");
                        itemMaterial.SetFloat("_Cutoff", 0.5f);
                        itemMaterial.SetColor("_MainColor", color);
                    }
                    itemMaterial.SetTexture("_DisolveGuide", textureDisolveGuide);
                    itemMaterial.SetFloat(dissolveAmountId, 1 - pro);
                }
                if (!mapMaterialForModel.ContainsKey(partInfo.part_name))
                {
                    mapMaterialForModel.Add(partInfo.part_name, listMaterial);
                }
            }
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 获取ID获取模型数据
    /// </summary>
    /// <param name="id"></param>
    /// <param name="action"></param>
    public void GetModelInfoById(long id, Action <ModelInfoBean> action)
    {
        ModelInfoBean modelInfo = GetModel().GetModelInfoById(id);

        if (modelInfo != null)
        {
            List <ModelPartInfoBean> listData = GetModel().GetModelPartInfoByModelId(modelInfo.id);
            modelInfo.listPartData = listData;
        }
        GetView().GetModelInfoSuccess(modelInfo, action);
    }
Exemplo n.º 5
0
 public void GetModelInfoSuccess(ModelInfoBean modelInfo, Action <ModelInfoBean> action)
 {
     action?.Invoke(modelInfo);
 }
Exemplo n.º 6
0
 public void SetData(ModelInfoBean modelInfo)
 {
     this.modelInfo = modelInfo;
     SetName(modelInfo.name + "(" + modelInfo.unlock_money + ")");
 }
Exemplo n.º 7
0
 public void SetData(UserModelDataBean userModelData, ModelInfoBean modelInfo)
 {
     gameModelProgress.SetData(userModelData, modelInfo);
 }