コード例 #1
0
 public void Init(UnityEngine.Config.Material mat)
 {
     shader = Resources.GetShader(mat.m_Shader);
     UnityEngine.Config.FileMap fms = mat.m_SavedProperties.m_TexEnvs[0].data.second.m_Texture;
     if (fms.IsEmpty())
     {
         mainTexture = null;
     }
     else
     {
         // Hack, need to read TextureImporter from fms.
         string guid = mat.m_SavedProperties.m_TexEnvs[0].data.second.m_Texture.guid;
         mainTexture         = Resources.GetTexture(guid);
         mainTextureOffset.x = mat.m_SavedProperties.m_TexEnvs[0].data.second.m_Offset.x;
         mainTextureOffset.y = mat.m_SavedProperties.m_TexEnvs[0].data.second.m_Offset.y;
         mainTextureScale.x  = mat.m_SavedProperties.m_TexEnvs[0].data.second.m_Scale.x;
         mainTextureScale.y  = mat.m_SavedProperties.m_TexEnvs[0].data.second.m_Scale.y;
     }
 }
コード例 #2
0
 private object CreateObjectByJsonAndType(object json, Type type)
 {
     // special case for field name not match.
     if (type.Name == "LayerMask")
     {
         var mask = Logic.Convert.ToInt32((json as Dictionary <string, object>)["m_Bits"]);
         var lm   = (LayerMask)mask;
         return(lm);
     }
     else
     {
         Dictionary <string, object> v = json as Dictionary <string, object>;
         if (v == null)
         {
             return(null);
         }
         if (v.ContainsKey("guid") && v["guid"] != null)
         {
             string      guid = v["guid"].ToString();
             ResourceMap map  = rmm.GetFromGuid(guid);
             if (map == null)
             {
                 return(null);
             }
             if (map.ext == "prefab")
             {
                 var prefab = Resources.LoadPrefab(guid);
                 var c      = prefab.GetComponent(type);
                 if (c == null)
                 {
                     return(prefab);
                 }
                 else
                 {
                     return(c);
                 }
             }
             else if (map.ext == "mat")
             {
                 return(Resources.GetMaterial(guid));
             }
             else if (map.ext == "png" || map.ext == "jpg" || map.ext == "jpeg")
             {
                 return(Resources.GetTexture(guid));
             }
             else if (map.ext == "shader")
             {
                 return(Resources.GetShader(FileMap.FromJson(v)));
             }
         }
         else if (v.ContainsKey("fileID") && v["fileID"] != null)
         {
             return(GetComponentByFileID(v["fileID"].ToString()));
         }
         else
         {
             var obj = Activator.CreateInstance(type);
             // Following way fails in Duocode lib.
             // var target = type.Assembly.CreateInstance(type.FullName);
             if (obj != null)
             {
                 InitObjectFromJson(obj, json, type);
             }
             return(obj);
         }
     }
     return(null);
 }
コード例 #3
0
ファイル: Application.cs プロジェクト: vladimir-tikhonov/UH5
 internal Texture GetTexture(string guid)
 {
     return(Resources.GetTexture(guid));
 }