Static variable from different class are not updated during the game in Webplayer

Hi,

I have a class where i store my variables that are public to all other functions. But the problem is that, it works when i test it in the unity editor, when i export it as web based application doesn’t work. After i search i found that the static variables are not updated.

Scenario: I have stored an variable in GenerealFunctions.cs which will be accessed from many other codes.
Example: When i call the method makeTrue() of the class aCode.cs with a UI button the variable theObject of the GeneralFunction.cs should be “true”. After that when i clicked up on a cube, or any other object where is attached the bcode.cs it should make should pass through the id statement (line 7) of the bCode.cs. This works when i test it in the unity platform, but when i export it as Web Player, doesn’t work.

GeneralFunctions.cs

using UnityEngine;
using System.Collections;
using System.IO;

public class GeneralFunctions {
static public bool newObject = false;
}

aCode.cs

using UnityEngine;
using System.Collections;

public class aCode : MonoBehaviour {

    public void makeTrue(){
        GeneralFunctions.newObject = true;
    }
}

bCode .cs

using UnityEngine;
using System.Collections;

public class bCode : MonoBehaviour {

    void OnMouseUp() {
        if(GeneralFunctions.newObject){
            print("make something");
             GeneralFunctions.newObject = false;
        }
    }
}

Any idea ???

Thank you in advance

ki_ha1984

Any idea?

I export it as pc application and it works, doesnot work only as web application.

I just did a quick test and did not run into any issues; here is what I did:

public class StaticClass
{
    public static bool Value = false;
}

[ExecuteInEditMode]
public class Test : MonoBehaviour
{
    [SerializeField]
    private Vector2 position;

    private void OnGUI( )
    {
        // Toggle value when button is clicked
        if(GUI.Button(new Rect(position.x, position.y, 100, 30), StaticClass.Value.ToString()))
        {
            StaticClass.Value = !StaticClass.Value;
        }
    }
}

I attached this to a sprite to test the OnMouseUp function

public class Test2 : MonoBehaviour
{
    private void OnMouseUp()
    {
        // Toggle value
        StaticClass.Value = !StaticClass.Value;
    }
}

Perhaps the problem could be that the object is not registering your clicks correctly. I would check the collider to make sure that it is capturing your mouse clicks

Did you try it exported as web application, i mean run it from browser ?

I tested it as a web application and a windows application and it worked on both cases.

i have some log error can you tell me if is there any problem with them .

141219 13:03:59 ------------------------------------------------------------
141219 13:03:59 Instance starting, version 4.6.1f1_d1db7a1b5196, UNITY_WEB_ENABLE_AUTODOWNLOAD: 1, GetDisableAutoUpdates(): 0
141219 13:03:59 Datafile file:///C:/Users/user/Desktop/Game/export191214/export191214.unity3d
141219 13:04:02 Timed out on global version info
web: player version 4.6.1f1
web: load mono
Mono path[0] = 'C:/Users/user/AppData/LocalLow/Unity/WebPlayer/player/Dev3.x.x/Data/lib'
Mono path[1] = 'C:/Users/user/AppData/LocalLow/Unity/WebPlayer/mono/Release3.x.x/Data/lib'
Mono config path = 'C:/Users/user/AppData/LocalLow/Unity/WebPlayer/mono/Release3.x.x/Data/etc'
web: start, src=export191214.unity3d abs=file:///C:/Users/user/Desktop/SysnthesisGame/export191214/export191214.unity3d flags=0x0
web: sucessfully initialized
141219 13:05:14 loader: start ok
141219 13:05:15 Times: download 73.8 load 2.7
Loading webdata version: 4.6.1f1
Initialize engine version: 4.6.1f1 (d1db7a1b5196)
GfxDevice: creating device client; threaded=0
d3d11: failed to create D3D11 device (0x887a0004)
GfxDevice: creating device client; threaded=0
Direct3D:
    Version:  Direct3D 9.0c [nvd3dum.dll 9.18.13.900]
    Renderer: NVIDIA Quadro FX 5500
    Vendor:   NVIDIA
    VRAM:     1006 MB (via DXGI)
    Caps:     Shader=30 DepthRT=1 NativeDepth=0 NativeShadow=1 DF16=0 INTZ=0 RAWZ=1 NULL=1 RESZ=0 SlowINTZ=0
Begin MonoManager ReloadAssembly
Platform assembly: C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Data\lib\UnityEngine.dll (this message is harmless)
Non platform assembly: C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Assembly-CSharp.dll (this message is harmless)
Loading C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Assembly-CSharp.dll into Unity Child Domain
Non platform assembly: C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Assembly-UnityScript-firstpass.dll (this message is harmless)
Loading C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Assembly-UnityScript-firstpass.dll into Unity Child Domain
Non platform assembly: C:\Users\useruser\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Assembly-UnityScript.dll (this message is harmless)
Loading C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Assembly-UnityScript.dll into Unity Child Domain
Non platform assembly: C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\UnityEngine.UI.dll (this message is harmless)
Loading C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\UnityEngine.UI.dll into Unity Child Domain
Non platform assembly: C:\Users\useruser\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Boo.Lang.dll (this message is harmless)
Loading C:\Users\useruser\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Boo.Lang.dll into Unity Child Domain
- Completed reload, in  0.124 seconds
<RI> Initializing input.

XInput1_3.dll not found.
<RI> Input initialized.

desktop: 1920x1200 59Hz; virtual: 1920x1200 at 0,0
Platform assembly: C:\Users\user\AppData\LocalLow\Unity\WebPlayer\mono\Release3.x.x\Data\lib\System.Core.dll (this message is harmless)
Platform assembly: C:\Users\user\AppData\LocalLow\Unity\WebPlayer\mono\Release3.x.x\Data\lib\System.dll (this message is harmless)

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/WebPlayerGenerated/UnityEngineDebug.cpp Line: 49)

Platform assembly: C:\Users\user\AppData\LocalLow\Unity\WebPlayer\player\Dev3.x.x\Data\lib\CrossDomainPolicyParser.dll (this message is harmless)
ID888 Position--> (0.0, 0.0, 0.0), Scale--> (1.0, 1.0, 1.0), Rotation--> (270.0, 0.0, 0.0)
(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/WebPlayerGenerated/UnityEngineDebug.cpp Line: 49)

SecurityException: No valid crossdomain policy available to allow access
  at (wrapper managed-to-native) UnityEngine.WWW:get_bytes ()

  at UnityEngine.WWW.get_text () [0x00000] in <filename unknown>:0

  at checkIfUserExist+<check4NameInServer>c__Iterator4.MoveNext () [0x00000] in <filename unknown>:0
(Filename:  Line: -1)

Have a look at this: http://docs.unity3d.com/Manual/SecuritySandbox.html

Your issue isn’t at all related to “static” variables not being updated. Generally check the log file before searching for the cause of a bug. That can cut down the time to find them significantly.

for the error of the 53 to 59 i have made a small change to code in order to found the error, now i correct it. but still have the same problem of non updating the static variable