コード例 #1
0
            public void ReplaceObject(MQO.MQOFormat format, int obj_id, GameObject obj, Mesh mesh, UnityEngine.Material[] materials)
            {
                MeshFilter filter = obj.AddComponent <MeshFilter>();

                filter.mesh = mesh;
                MeshRenderer mren = obj.AddComponent <MeshRenderer>();

                mren.sharedMaterials = materials;
                for (int Set = 0; Set < mren.sharedMaterials.Length; Set++)
                {
                    MQO.MQOFormat.Material mqoMat = format.material_list.material[Set];
                    if (mren.sharedMaterials[Set].shader = Shader.Find("Metasequoia/Phong"))
                    {
                        mren.sharedMaterials[Set].SetFloat("_Spec", mqoMat.spc);
                    }
                }
            }
コード例 #2
0
            //You must make mqo shader switch
            //Create Material Object
            void EntryColors(MQO.MQOFormat format, Material[] mats)
            {
                // マテリアルの生成
                for (int i = 0; i < mats.Length; i++)
                {
                    // mqoフォーマットのマテリアルを取得
                    MQO.MQOFormat.Material mqoMat = format.material_list.material[i];
                    switch (mqoMat.shader)
                    {
                    case 0:
                        mats[i] = new Material(Shader.Find("Diffuse"));
                        break;

                    case 1:
                        mats[i] = new Material(Shader.Find("Metasequoia/Constant"));
                        break;

                    case 3:
                        mats[i] = new Material(Shader.Find("Metasequoia/Phong"));
                        break;

                    default:
                        mats[i] = new Material(Shader.Find("Diffuse"));
                        break;
                    }
                    mats[i].color = mqoMat.col;

                    // テクスチャが空でなければ登録
                    if (mqoMat.tex != "")
                    {
                        string path = format.folder + "/" + mqoMat.tex;
                        mats[i].mainTexture      = AssetDatabase.LoadAssetAtPath(path, typeof(Texture)) as Texture;
                        mats[i].mainTextureScale = new Vector2(1, -1);
                    }
                }
            }