HOT FIX for FADING "Lootable" models

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

HOT FIX for FADING "Lootable" models

Postby Adam » 09 May 2011, 11:07

I have discovered two things:
(http://theantranch.com/forum/viewtopic.php?f=25&t=1174)
* A translation/code error in the fade method (This is in the UnityScript.js (JS) version only!)
* An architectural problem with complex models (This is in both versions)

One is a C#->JS translation error and is present in the UnityScript.js (JS) version only. 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

OBSOLETE

SEE FIX BELOW


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.

User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

HOT FIX for FADING *complex* "Lootable" models

Postby Adam » 09 May 2011, 11:55

Replace DestroyFade() in LootableBase.cs/js



C#

Code: Select all


   protected IEnumerator DestroyFade () {
      //   Optionally fade out the material first, or some other visual effect
      lootPanelOpen = false;
      inventoryManager.CloseLootWindow ();
      yield return new WaitForSeconds (delayBeforeDestroying);
      Renderer[] renderers = gameObject.GetComponentsInChildren <Renderer>();         //   This could be optimized into Awake() or Start()
      foreach (Renderer thisRenderer in renderers) {
         foreach(Material mat in thisRenderer.materials) {
            if (mat.shader.name != "Transparent/Diffuse")                     //   This could be optimized into Awake() or Start()
               mat.shader = Shader.Find ("Transparent/Diffuse");
            StartCoroutine(FadeMaterial(mat, fadeDuration));
         }
      }
      Destroy (gameObject,fadeDuration + 0.1f);
   }



UnityScript.js (JS)

Code: Select all

protected function DestroyFade () {
   //   Optionally fade out the faterial first, or some other visual effect
   lootPanelOpen = false;
   inventoryManager.CloseLootWindow ();
   yield WaitForSeconds (delayBeforeDestroying);
   var renderers : Renderer[] = gameObject.GetComponentsInChildren.<Renderer>();   //   This could be optimized into Awake() or Start()
   for (var thisRenderer : Renderer in renderers) {
      for (var mat : Material in thisRenderer.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);
}


This fix is imperfect, but currently I'm unclear what the best solution is, as this seems to be an issue with the way that Unity is rendering the transparent shader. Unity can handle simple objects, like a box, and fade it correctly, but with a complex model like the chest, the renderer seems to be confused by what part of the box is where. I believe this is because the rendering is based on the center point?

I'll keep this thread updated as to the best way to handle fading complex objects.

User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

Re: HOT FIX for FADING "Lootable" models

Postby Adam » 09 May 2011, 13:31

HOT FIX is available on the eStore.
Re-download your code according to the eStore receipt you received when purchasing.

Let me know if there are any issues.

User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

Re: HOT FIX for FADING "Lootable" models

Postby Adam » 11 May 2011, 01:00

And all those buggeringly normal questions: You have "destroy when empty" checked? and "fade before destoying"?
Image

I would imaging you have, but it's always worth checking...

I've just tested it here at my end and it works. I had missed the method call when I translated this one. In C# one must explicitly call "StartCoroutine( FadeMaterial(mat, fadeDuration));" and I removed the "StartCoroutine" but never included the method FadeMaterial(mat, fadeDuration); D'oh! Missed that one. And we all missed it while playtesting. Seen it too much I guess.

As it's working here I think the best thing to do would be to re-download the software using your original receipt and you'll get a new package. This should iron out any issues and may fix/optimize other bits and pieces. You don't need to import everything (the FULL package), but can reimport the BASIC package. This will simply replace the scripts in the package.

This is what they say:
eSellerate wrote:"If you have previously purchased a license, you can download the very latest version via After-Purchase Services, at http://store.esellerate.net/support. Please log on using your e-mail address and your original order ID (found in your receipt and in your Order Confirmation e-mail message), and then click the here link in the Re-download section after logging on. This will display your original receipt, complete with a DOWNLOAD NOW button you can use to download the latest version of the product."


Check the file that eSellerate delivers to you. It should be: "InventoryManagerJS_2-0-1.zip"

If this doesn't work, or you can't do it, then PM me your name, address and activation code, and I'll send you the files directly.


Return to “Inventory (for Unity Gui)”

Who is online

Users browsing this forum: No registered users and 1 guest