playMaker

Author Topic: [SOLVED] Global Var Setting Fail: "Inaccessible due to protection level"  (Read 2280 times)

memetic arts

  • Full Member
  • ***
  • Posts: 141
Greetings -

I understand the basics of FSM-to-script variable setting, but am currently getting an error when I attempt to assign an instantiated Texture2D to an Object>Texture2D global in PM. The error reads:

"Assets/Scripts/LoadAB.cs(42,75): error CS0122: `HutongGames.PlayMaker.FsmObject.value' is inaccessible due to its protection level"

And the code in question:

Code: [Select]
Texture2D tex = request.asset as Texture2D;

if (tex != null){
        var tx = Texture2D.Instantiate(tex);
FsmVariables.GlobalVariables.GetFsmObject("tx01").value = tx;
}

Note that the instantiation happens after the texture is downloaded via an assetbundle, and according to logs, etc., the download is successful. What I'm trying to do here is assign the instantiated texture to a variable so I can add it to a Hashtable, and then apply it to another GameObject. (I suppose I don't really need the variable "tx" in the script, was just another attempt at assignment).

I'd really appreciate some input here -- as in the past, I can usually figure these things out, but I'm in a bit of a time crunch so could really use the assist.

Thanks in advance!

==rr
« Last Edit: January 30, 2016, 04:00:53 PM by memetic arts »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Global Var Setting Fail: "Inaccessible due to protection level"
« Reply #1 on: January 29, 2016, 12:54:08 AM »
Hi,

 Should you not try to get a FsmTexture to save a texture?


Try to save the Fsmxxx into a variable first and then see if you can set it's value then.

Bye,

 Jean

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: Global Var Setting Fail: "Inaccessible due to protection level"
« Reply #2 on: January 29, 2016, 08:45:02 AM »
Hi Jean, thanks for the reply.  Maybe I did overlook that, I'll try it. 

But here's the bigger picture . . . maybe you can confirm if my strategy makes sense. The textures are used in an NGUI submenu that consists of a collection/list of sprites that are generated from a prefab when the users clicks a button on the main menu (by running through a Hashtable GetNext operation).

My thought was that to avoid perception of lag, I should load the assetbundle textures when the app first starts, store them in a correlating Hashtable, and then just assign them when the prefab/menu items are generated.

The problem basically is that while I seem to be successfully loading from the assetbundle, I can't actually access the textures to do anything with them - they aren't even appearing in the Hierarchy after instantiation, which seems odd, no?

Anyway, I'll try what you suggested, and I have one other fall-back idea to try, and we'll see.  Really don't want to throw up the white flag on this one! :-)

Thanks again for your input, Jean, always appreciated.




Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3998
  • Official Playmaker Support
    • LinkedIn
Re: Global Var Setting Fail: "Inaccessible due to protection level"
« Reply #3 on: January 30, 2016, 01:54:40 AM »
You need a capital V, Value not value.

memetic arts

  • Full Member
  • ***
  • Posts: 141
Global Var Setting Fail: "Inaccessible due to protection level"
« Reply #4 on: January 30, 2016, 03:59:55 PM »
OMG, Alex, THAT WAS IT!!

Huge thanks!!

(For the record, Jean, I did go ahead and actually try assignment to FSM Textures, and while I was able to populate the HashTable, the HT only showed a count, not the actual values.  But now, withe direct variable assignment working per above, the HT gets populated and all the values appear as expected.)

Again, MANY THANKS!!