示例#1
0
    public GameObject CreateSticker(PPPrefabInfo info, Action loadFinish = null)
    {
        if (info == null)
        {
            throw new ArgumentNullException("PPPrefabInfo can't be null!");
        }
        string     matPath   = Path.Combine(AppBlockPath(BlockPath.Sticker_Material_Dir), info.Name);
        var        modelPath = Path.Combine(PrefixPath, info.Model + "/" + info.Model + ".gltf");
        GameObject sticker   = null;

        sticker = PTGLTFLoader.loadGltf(modelPath, () =>
        {
            var stickerRoot = sticker.transform.Find("Root Scene");
            var render      = stickerRoot == null ? null : stickerRoot.GetComponentInChildren <Renderer>(true);
            if (render != null)
            {
                Material mat             = PBMatLoader.LoadTextureMatAsset(matPath, info.Texture, true);
                render.receiveShadows    = false;
                render.shadowCastingMode = ShadowCastingMode.Off;
                render.sharedMaterial    = mat;
            }
            else
            {
                PTDebug.LogError("Sticker:<color=#FF00FF>{0}</color> load failed! Model:<color=#FF00FF>{1}</color>", info.Name, info.Model);
            }
            loadFinish.InvokeGracefully();
        }, OnInitializeGltfObject);
        blockObj.Add(sticker);

        return(sticker);
    }
示例#2
0
    public GameObject CreateTexture(PPPrefabTexInfo info, Action loadFinish = null)
    {
        if (info == null)
        {
            throw new ArgumentNullException("PPPrefabInfo can't be null!");
        }
        var    prefabName = info.Name;
        string matPath    = Path.Combine(AppBlockPath(BlockPath.Texture_Material_Dir), prefabName);

        var model     = info.Model;
        var modelPath = Path.Combine(AppBlockPath(BlockPath.Texture_Fbx_Dir), model);

        modelPath = modelPath + "/" + model + ".gltf";

        GameObject texObj = null;

        texObj = PTGLTFLoader.loadGltf(modelPath, () =>
        {
            var texRoot = texObj.transform.Find("Root Scene");
            var render  = texRoot == null ? null : texRoot.GetComponentInChildren <Renderer>(true);
            if (render != null)
            {
                Material mat             = PBMatLoader.LoadTextureMatAsset(matPath, info.Texture, false);
                render.receiveShadows    = false;
                render.shadowCastingMode = ShadowCastingMode.Off;
                render.material          = mat;
            }
            else
            {
                PTDebug.LogError("Texture:<color=#FF00FF>{0}</color> load failed! Model:<color=#FF00FF>{1}</color>", prefabName, model);
            }
            loadFinish.InvokeGracefully();
        }, OnInitializeGltfObject);

        texObj.name = prefabName;
        blockObj.Add(texObj);

        return(texObj);
    }