private static void ProcessPrefabTexInfo(XmlNode node, List <PPPrefabTexInfo> texInfo)
    {
        var texNodes = node.SelectNodes("tex");

        for (int i = 0; i < texNodes.Count; i++)
        {
            XmlNode         texNode    = texNodes[i];
            PPPrefabTexInfo prefabInfo = new PPPrefabTexInfo();
            prefabInfo.Name    = texNode.Attributes["name"].Value;
            prefabInfo.Texture = texNode.Attributes["texture"].Value;
            prefabInfo.Model   = texNode.Attributes["model"].Value;
            texInfo.Add(prefabInfo);
        }
    }
示例#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);
    }