Example #1
0
 // ----------- Submit ------------------------
 void Apply()
 {
     if (m_Target != null)
     {
         ulong old_guid           = 0;
         ulong new_guid           = 0;
         bool  need_update_isomat = (VCEditor.s_Scene.m_IsoData.QueryMaterial(m_Target.m_Guid) != null);
         if (VCEAssetMgr.s_Materials.ContainsKey(m_Target.m_Guid))
         {
             old_guid = m_Target.m_Guid;
             if (!VCEAssetMgr.DeleteMaterialDataFile(m_Target.m_Guid))
             {
                 VCEMsgBox.Show(VCEMsgBoxType.MATERIAL_NOT_SAVED);
             }
             VCEAssetMgr.s_Materials.Remove(m_Target.m_Guid);
             m_Target.Import(m_TempMaterial.Export());
             new_guid = m_Target.m_Guid;
             VCEAssetMgr.s_Materials.Add(m_Target.m_Guid, m_Target);
             if (!VCEAssetMgr.CreateMaterialDataFile(m_Target))
             {
                 VCEMsgBox.Show(VCEMsgBoxType.MATERIAL_NOT_SAVED);
             }
         }
         else if (VCEAssetMgr.s_TempMaterials.ContainsKey(m_Target.m_Guid))
         {
             old_guid = m_Target.m_Guid;
             VCEAssetMgr.s_TempMaterials.Remove(m_Target.m_Guid);
             m_Target.Import(m_TempMaterial.Export());
             new_guid = m_Target.m_Guid;
             VCEAssetMgr.s_TempMaterials.Add(m_Target.m_Guid, m_Target);
         }
         else
         {
             Debug.LogError("What the hell is that ?!");
             old_guid = m_Target.m_Guid;
             m_Target.Import(m_TempMaterial.Export());
             new_guid = m_Target.m_Guid;
             VCEAssetMgr.s_Materials.Add(m_Target.m_Guid, m_Target);
             if (!VCEAssetMgr.CreateMaterialDataFile(m_Target))
             {
                 VCEMsgBox.Show(VCEMsgBoxType.MATERIAL_NOT_SAVED);
             }
         }
         VCEAlterMaterialMap.MatChange(old_guid, new_guid);
         if (need_update_isomat)
         {
             VCEditor.s_Scene.GenerateIsoMat();
         }
         VCEditor.SelectedMaterial = m_Target;
         VCEditor.Instance.m_UI.m_MaterialList.RefreshMaterialListThenFocusOnSelected();
         VCEditor.SelectedMaterial = m_Target;
     }
     else
     {
         Debug.LogError("No target material, Create new material instead !");
         CreateAsNew();
     }
 }
Example #2
0
    void CreateAsNew()
    {
        VCMaterial newmat = new VCMaterial();

        newmat.Import(m_TempMaterial.Export());
        VCEAssetMgr.s_Materials.Add(newmat.m_Guid, newmat);
        if (!VCEAssetMgr.CreateMaterialDataFile(newmat))
        {
            VCEMsgBox.Show(VCEMsgBoxType.MATERIAL_NOT_SAVED);
        }

        VCEditor.SelectedMaterial = newmat;
        VCEditor.Instance.m_UI.m_MaterialList.RefreshMaterialListThenFocusOnSelected();
        VCEditor.SelectedMaterial = newmat;
        Reset(newmat);
        VCEStatusBar.ShowText("New Material".ToLocalizationString() + " [" + newmat.m_Name + "]", 6f, true);
    }