Lootable Item destroy on empty

Discussions, Solutions & How To with Inventory
User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

Re: Lootable Item destroy on empty

Postby Adam » 09 May 2011, 11:03

Nope, you've not missed anything. I missed something.

Your question had led me to discover two things:
* A translation/code error in the fade method
* An architectural problem with complex models

One is a JS translation error, which I find astounding that neither I nor my play-testers noticed. Objects are not fading in the JS version because of an error in the fade function. This is a simple fix. In "LootableBase.js" change function DestroyFade to this:

Code: Select all

protected function DestroyFade () {
   //   Optionally fade out the faterial first, or some other visual effect
   lootPanelOpen = false;
   inventoryManager.CloseLootWindow ();
   yield WaitForSeconds (delayBeforeDestroying);
   for (var mat : Material in renderer.materials) {
      if (mat.shader.name != "Transparent/Diffuse")                     //   This could be optimized into Awake() or Start()
         mat.shader = Shader.Find ("Transparent/Diffuse");
         FadeMaterial(mat, fadeDuration);
   }
   Destroy (gameObject,fadeDuration + 0.1f);
}


The other is a more complicated issue, which is, I need to grab the renderers of the *CHILDREN* in complex models, such as the animated chest. As the LootableObject script is on the Parent Transform containing the 3 models of the animated chest, not on a 3D model itself, I need to be more clever about how I grab the materials for complex objects with family trees.

Give me a moment, and I'll post a fix for this.

Return to “Inventory (for Unity Gui)”

Who is online

Users browsing this forum: No registered users and 1 guest