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 Hat = AssetBundle.LoadAsset <GameObject>("_Hat"); foreach (Collider collider in Hat.GetComponentsInChildren <Collider>()) { collider.enabled = false; // Disable colliders. They can be left in accidentally and cause some really weird issues. } // Make Descriptor Descriptor = PackageUtils.ConvertJsonToHat(json); Debug.Log(Descriptor.AuthorName); } catch (Exception err) { // loading failed. that's not good. Debug.Log(err); } } }
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 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; } }