Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Game does not run the same on device/4.6.1p2

Discussion in 'Android' started by gallenwolf, Jan 5, 2015.

  1. gallenwolf

    gallenwolf

    Joined:
    Mar 11, 2012
    Posts:
    118
    Hello!
    I recently upgraded to the new patch version of Unity, 4.6.1p2 to fix the crashes on Android 5 devices. The game runs exactly how I want it inside the editor + unity remote. However, when I run the game on my android devices (Nexus 4, Galaxy Tab 3 7.0), many scripts do not work the same!

    I'm wondering if anyone else has seen this issue.... the only change was to include the patch. Previously on 4.6.1, it works great on my Galaxy Tab (android 4.1.2), but crashes on my Nexus 4 (android 5.0.1). Now, the game works on both devices, but the scripts are totally out of whack >.>

    It's rather late and I need to turn in, but I'll see if I can post some videos of this in action tomorrow.

    Cheers!
     
  2. Sansidiok

    Sansidiok

    Joined:
    Mar 19, 2013
    Posts:
    5
  3. gallenwolf

    gallenwolf

    Joined:
    Mar 11, 2012
    Posts:
    118
    Hey Sansidiok! Thanks for the suggestion. I figured out what's causing the problem on my end. It is one of the shaders I cobbled together. Somehow, with 4.6.1p2 this shader works fine on the editor, but not in the device. I'll be uploading a sample project shortish.
     
  4. gallenwolf

    gallenwolf

    Joined:
    Mar 11, 2012
    Posts:
    118
    Ok, so here's a sample project demonstrating the problem I encountered. It might be my fault cobbling a shader, but it works on Unity 4.6.1 and works in the editor....

    If you would extract this zip file and load it in the editor, you should see 3 spheres approaching the camera. Two of them have child objects that are assigned a solid color shader, while the last uses a built in shader

    However, if I Build and Run this project on my Galaxy Tab 3 7.0 (SM-T210R), Android version 4.1.2, the first two spheres (parent objects) move as expected towards camera.

    The child objects however, hover at (probably) z=0. And what's fun, is on my device, when the sphere parent objects move past z=0. the child object snaps onto the parent object and follows along! >.<

    The 3rd object, using the regular shader, is fine.

    So this points to my shader being wrong, but it works find in the editor, and earlier builds!
     

    Attached Files:

    Last edited: Jan 7, 2015
  5. gallenwolf

    gallenwolf

    Joined:
    Mar 11, 2012
    Posts:
    118
    This is the code I cobbled together from the unity code sources: It's a very basic solid color shader that has a sin function modulating the color.

    Code (CSharp):
    1. Shader "GWCustom/glowPulseCG" {
    2.     Properties {
    3.         _GlowColor ("Glow Color", Color) = (0,1,0,1)
    4.         _GlowSpeed ("Glow Speed", Range(0.1,50)) = 5
    5.     }
    6.    SubShader { // Unity chooses the subshader that fits the GPU best
    7.       Pass { // some shaders require multiple passes
    8.          CGPROGRAM // here begins the part in Unity's Cg
    9.          #pragma vertex vert
    10.          #pragma fragment frag
    11.        
    12.          uniform float4 _GlowColor;                
    13.          uniform half _GlowSpeed;
    14.  
    15.          float4 vert(float4 vertexPos : POSITION) : SV_POSITION
    16.             // vertex shader
    17.          {
    18.             return mul(UNITY_MATRIX_MVP, vertexPos);
    19.  
    20.          }
    21.          float4 frag(void) : COLOR // fragment shader
    22.          {
    23.              half multiplier = 0.7 + (sin(_Time.y * _GlowSpeed)*0.3) ;
    24.             return  _GlowColor * multiplier ;
    25.  
    26.          }
    27.          ENDCG // here ends the part in Cg
    28.       }
    29.    }
    30. }
    31.  
     
  6. gallenwolf

    gallenwolf

    Joined:
    Mar 11, 2012
    Posts:
    118
    Has been reported as
    Case 661422

    in case it's a real bug and not just my stupidity.