Example #1
0
        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 static HatDescriptor ConvertJsonToHat(PackageJSON json)
        {
            HatDescriptor Descriptor = new HatDescriptor();

            Descriptor.HatName              = 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);
        }