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.ConvertJsonToDescriptor(json); } catch (Exception err) { // loading failed. that's not good. Debug.Log(err); throw new Exception($"Loading material at {path} failed."); } } else { // try to load the default material Descriptor = new CosmeticDescriptor(); Descriptor.Name = "Default"; Descriptor.CustomColors = true; material = Resources.Load <Material>("objects/treeroom/materials/lightfur"); } }
public GorillaHat(string path) { if (path != "Default") { try { FileName = path; var bundleAndJson = PackageUtils.AssetBundleAndJSONFromPackage(FileName); assetBundle = bundleAndJson.bundle; PackageJSON json = bundleAndJson.json; // get material object and stuff assetTemplate = assetBundle.LoadAsset <GameObject>("_Hat"); foreach (Collider collider in assetTemplate.GetComponentsInChildren <Collider>()) { collider.enabled = false; // Disable colliders. They can be left in accidentally and cause some really weird issues. } assetTemplate.SetActive(false); // Make Descriptor Descriptor = PackageUtils.ConvertJsonToDescriptor(json); } catch (Exception err) { // loading failed. that's not good. Debug.LogError(err); throw new Exception($"Loading hat at {path} failed."); } } else { Descriptor = new CosmeticDescriptor(); Descriptor.Name = "Default"; assetTemplate = null; } }