Animation working in Unity and PC build, but not Android
I have a simple sceneFade script that works fine in Unity 5.4.0f3 and in the PC build. But does not work at all in Android 4.4.2 build on Android phone v4.4.2.
I searched Unity Answers and the web but didn't see one like this. Any suggestions?
 using UnityEngine;
 using System.Collections;
 
 public class CollisionAnim : MonoBehaviour {
 
     // Play anim on collision with correct object
     void OnTriggerEnter (Collider col)
     {
         if(col.gameObject.name == "PlanetEarthObject")
         {
             GetComponent<Animation>().Play ("sceneFade");
         }    
 
     }
 }
Answer by DarkNode · Aug 27, 2016 at 07:01 PM
Bump.
This is my first time building for Android.
Do I need to do something special in the build to get this animation to work?
Or change in syntax?
I tested the anim with an audio source. This plays correctly in Android. Just the sceneFade doesn't play.
Here's the code for the excellent ScreenFader script:
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class ScreenFader : MonoBehaviour
 {
     public bool fadeIn = true;
     public float fadeTime = 2.0f;
     public Color fadeColor = new Color(0.0f, 0.0f, 0.0f, 1.0f);
     public Material fadeMaterial = null;
     
     private bool faded = false;
     private bool lastFadeIn = false;
     private List<ScreenFadeControl> fadeControls = new List<ScreenFadeControl>();
 
 
     void SetFadersEnabled(bool value)
     {
         foreach (ScreenFadeControl fadeControl in fadeControls)
             fadeControl.enabled = value;
     }
 
     public IEnumerator FadeOut()
     {
         if (!faded)
         {
             // Derived from OVRScreenFade
             float elapsedTime = 0.0f;
             Color color = fadeColor;
             color.a = 0.0f;
             fadeMaterial.color = color;
             while (elapsedTime < fadeTime)
             {
                 yield return new WaitForEndOfFrame();
                 elapsedTime += Time.deltaTime;
                 color.a = Mathf.Clamp01(elapsedTime / fadeTime);
                 fadeMaterial.color = color;
             }
         }
         faded = true;
     }
 
     public IEnumerator FadeIn()
     {
         if (faded)
         {
             float elapsedTime = 0.0f;
             Color color = fadeMaterial.color = fadeColor;
             while (elapsedTime < fadeTime)
             {
                 yield return new WaitForEndOfFrame();
                 elapsedTime += Time.deltaTime;
                 color.a = 1.0f - Mathf.Clamp01(elapsedTime / fadeTime);
                 fadeMaterial.color = color;
             }
         }
         faded = false;
         SetFadersEnabled(false);
     }
 
     public void Update()
     {
         if (lastFadeIn != fadeIn)
         {
             lastFadeIn = fadeIn;
             StartCoroutine(DoFade());
         }
     }
     
     public IEnumerator DoFade()
     {
         // Clean up from last fade
         foreach (ScreenFadeControl fadeControl in fadeControls)
         {
             Destroy(fadeControl);
         }
         fadeControls.Clear();
         
         // Find all cameras and add fade material to them (initially disabled)
         foreach (Camera c in Camera.allCameras)
         {
             var fadeControl = c.gameObject.AddComponent<ScreenFadeControl>();
             fadeControl.fadeMaterial = fadeMaterial;
             fadeControls.Add(fadeControl);
         }
 
         // Do fade
         if (fadeIn)
             yield return StartCoroutine(FadeIn());
         else
             yield return StartCoroutine(FadeOut());
     }
 }
 
The sceneFade anim component and the collision script are both on the spaceship gameobject... The audio works but not the scene fade, which uses a empty gameobject childed to the spaceship to fade to black.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                