Ejemplo n.º 1
0
        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");
            }
        }