예제 #1
0
        public virtual LMVTexture texture(int index)
        {
            JSONNode   json = this [index];
            LMVTexture tex  = new LMVTexture();

            if (json ["definition"] == "UnifiedBitmap")
            {
                tex.tex = json ["properties"] ["uris"] ["unifiedbitmap_Bitmap"];
            }
            else if (json ["definition"] == "BumpMap")
            {
                tex.tex = json ["properties"] ["uris"] ["bumpmap_Bitmap"];
            }
            tex.ur     = json ["properties"] ["booleans"] ["texture_URepeat"] ["values"] [0].AsBool;
            tex.vr     = json ["properties"] ["booleans"] ["texture_VRepeat"] ["values"] [0].AsBool;
            tex.invert = false;
            if (json ["properties"] ["booleans"] ["unifiedbitmap_Invert"] != null)
            {
                tex.invert = json ["properties"] ["booleans"] ["unifiedbitmap_Invert"] ["values"] [0].AsBool;
            }
            tex.channel   = json ["properties"] ["integers"] ["texture_MapChannel"] ["values"] [0].AsInt;
            tex.u         = json ["properties"] ["scalars"] ["texture_UScale"] ["values"] [0].AsFloat;
            tex.v         = json ["properties"] ["scalars"] ["texture_VScale"] ["values"] [0].AsFloat;
            tex.RGBAmount = 1.0f;
            if (json ["properties"] ["scalars"] ["unifiedbitmap_RGBAmount"] != null)
            {
                tex.RGBAmount = json ["properties"] ["scalars"] ["unifiedbitmap_RGBAmount"] ["values"] [0].AsFloat;
            }
            return(tex);
        }
예제 #2
0
        protected static void CreateMaterialTex(int id, LMVTexture lmvtex, string shaderKey, ref Material mat)
        {
            try {
                byte [] bytes    = File.ReadAllBytes(_svfDir + @"\" + lmvtex.tex.Replace('/', '\\'));
                string  filename = Path.GetFileName(lmvtex.tex);
                string  assetref = _resources + "/" + filename;
#if UNITY_EDITOR
                //FileStream file =File.Create (assetref) ;
                //file.Write (bytes, 0, bytes.Length) ;
                //file.Close () ;
                File.WriteAllBytes(assetref, bytes);
                AssetDatabase.Refresh();
#endif
                Texture2D tex = AssetDatabase.LoadAssetAtPath <Texture2D> (assetref);
                //tex.
                mat.SetTexture(shaderKey, tex);
                //mat.mainTexture =tex ;
                //mat.SetColor ("_Color", Color.black) ;
                //mat.SetTexture ("_MainTex", tex) ;
                //mat.SetTexture ("_SpecGlossMap", tex) ;
            } catch (System.Exception /*e*/) {
            }
        }