public GorillaMaterial(string path) { if (path != "Default") { try { // load FileName = path; var bundleAndJson = PackageUtils.AssetBundleAndJSONFromPackage(FileName); AssetBundle = bundleAndJson.bundle; PackageJSON json = bundleAndJson.json; // get material object and stuff GameObject materialObject = AssetBundle.LoadAsset <GameObject>("_Material"); Material = materialObject.GetComponent <Renderer>().material; // Make Descriptor Descriptor = PackageUtils.ConvertJsonToMaterial(json); } catch (Exception err) { // loading failed. that's not good. Debug.Log(err); } } else { // try to load the default material Descriptor = new GorillaMaterialDescriptor(); Descriptor.MaterialName = "Default"; Descriptor.CustomColors = true; Material = Resources.Load <Material>("objects/treeroom/materials/lightfur"); } }
public static GorillaMaterialDescriptor ConvertJsonToMaterial(PackageJSON json) { GorillaMaterialDescriptor Descriptor = new GorillaMaterialDescriptor(); Descriptor.MaterialName = json.descriptor.objectName; Descriptor.AuthorName = json.descriptor.author; Descriptor.Description = json.descriptor.description; Descriptor.CustomColors = json.config.customColors; Descriptor.DisablePublicLobbies = json.config.disableInPublicLobbies; return(Descriptor); }