static bool LoadMaterialPalette(out Material[] materials) { pb_ObjectArray poa = (pb_ObjectArray)AssetDatabase.LoadAssetAtPath(USER_MATERIALS_PATH, typeof(pb_ObjectArray)); if (poa != null) { materials = poa.GetArray <Material>(); return(true); } else { materials = new Material[10] { pb_Constant.DefaultMaterial, null, null, null, null, null, null, null, null, null }; return(false); } }
void SaveUserMaterials() { pb_ObjectArray poa = (pb_ObjectArray)ScriptableObject.CreateInstance(typeof(pb_ObjectArray)); poa.array = materials; if (!System.IO.Directory.Exists("Assets/ProCore")) { AssetDatabase.CreateFolder("Assets/", "ProCore"); } if (!System.IO.Directory.Exists("Assets/ProCore/ProBuilder")) { AssetDatabase.CreateFolder("Assets/ProCore/", "ProBuilder"); } if (!System.IO.Directory.Exists("Assets/ProCore/ProBuilder/Data")) { AssetDatabase.CreateFolder("Assets/ProCore/ProBuilder", "Data"); } AssetDatabase.CreateAsset(poa, USER_MATERIALS_PATH); AssetDatabase.SaveAssets(); }