示例#1
0
 // Create decal data file
 public static bool CreateDecalDataFile(VCDecalAsset vcdcl)
 {
     try
     {
         byte[]     buffer = vcdcl.Export();
         ulong      guid   = CRC64.Compute(buffer);
         string     sguid  = guid.ToString("X").PadLeft(16, '0');
         FileStream fs     = new FileStream(VCConfig.s_DecalPath + sguid + VCConfig.s_DecalFileExt, FileMode.Create, FileAccess.ReadWrite);
         fs.Write(buffer, 0, buffer.Length);
         fs.Close();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
示例#2
0
    public void OnOKClick()
    {
        if (m_ErrorLabel.text.Trim().Length < 1 && m_TmpDecal != null && m_TmpDecal.m_Tex != null)
        {
            VCDecalAsset newdcl = new VCDecalAsset();
            newdcl.Import(m_TmpDecal.Export());
            VCEAssetMgr.s_Decals.Add(newdcl.m_Guid, newdcl);
            if (!VCEAssetMgr.CreateDecalDataFile(newdcl))
            {
                VCEMsgBox.Show(VCEMsgBoxType.DECAL_NOT_SAVED);
            }

            VCEditor.SelectedDecal = newdcl;
            VCEditor.Instance.m_UI.m_DecalList.RefreshDecalList();
            VCEditor.SelectedDecal = newdcl;

            VCEStatusBar.ShowText("Added new decal".ToLocalizationString() + " !", 4f, true);
        }
    }
示例#3
0
 // Send some default decals if user's decal count is 0
 private static void SendDefaultDecals()
 {
     for (int i = 0; i < 6; ++i)
     {
         TextAsset ta = Resources.Load("Decals/Default" + i.ToString("00")) as TextAsset;
         if (ta == null)
         {
             continue;
         }
         VCDecalAsset vcdcl = new VCDecalAsset();
         vcdcl.Import(ta.bytes);
         try
         {
             byte[]     buffer = vcdcl.Export();
             ulong      guid   = CRC64.Compute(buffer);
             string     sguid  = guid.ToString("X").PadLeft(16, '0');
             FileStream fs     = new FileStream(VCConfig.s_DecalPath + sguid + VCConfig.s_DecalFileExt, FileMode.Create, FileAccess.ReadWrite);
             fs.Write(buffer, 0, buffer.Length);
             fs.Close();
         }
         catch (Exception e)
         {
             vcdcl.Destroy();
             Debug.LogError("Save decal [" + vcdcl.GUIDString + "] failed ! \r\n" + e.ToString());
             continue;
         }
         if (s_Decals.ContainsKey(vcdcl.m_Guid))
         {
             s_Decals[vcdcl.m_Guid].Destroy();
             s_Decals[vcdcl.m_Guid] = vcdcl;
         }
         else
         {
             s_Decals.Add(vcdcl.m_Guid, vcdcl);
         }
     }
 }