playMaker

Author Topic: Resources Load  (Read 38090 times)

lejeux16

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Resources Load
« Reply #15 on: February 08, 2015, 04:39:00 PM »
Where is the link to download "Resources Load"? Maybe I missed something but I don't understand where I can find it.

lejeux16

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Resources Load
« Reply #16 on: February 08, 2015, 05:05:21 PM »
I copy the action ResourcesLoad.cs in the action folder but I have a error in the unity log:

Assets/PlayMaker/Actions/ResourcesLoad.cs(18,24): error CS0246: The type or namespace name `FsmVar' could not be found. Are you missing a using directive or an assembly reference?

What is this mean?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Resources Load
« Reply #17 on: February 17, 2015, 01:31:43 AM »
Hi,

It's likely that you have errors in your project, can you double check that this is the only error you have in the console?

 else, are you sure you have PlayMaker installed? the latest from the Asset store?

 Bye,

 Jean

Budde88

  • Full Member
  • ***
  • Posts: 165
Re: Resources Load
« Reply #18 on: February 28, 2015, 08:14:41 AM »
I was wondering if there was a way to load a whole folder full of assets within the Resources folder. Load All Assets Resources/ExampleFolder.

I am having issues with this Resources Load script. It will Load Some Textures, but then it just won't load others...

But I would like the ability to do what I mentioned above, is this possible?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Resources Load
« Reply #19 on: February 28, 2015, 11:13:43 AM »
Hi,

 it should load any of the textures you have in your resources, if it doesn't work, it's likely a problem with the path you express to reach that texture.

 Use Asset Bundles if you want to load a series of textures or content in one go.

 Bye,

 Jean

phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: Resources Load
« Reply #20 on: June 30, 2015, 09:33:48 AM »
Seems that the action actually included in the Ecosystem doesn't work out of the box with unity 5 and should it be able to load sprites as well? Since I get following error if I use the action from this thread to pull a sprite:

InvalidCastException: Cannot cast from source type to destination type.
HutongGames.PlayMaker.Actions.uGuiImageSetSprite.DoSetImageSourceValue () (at Assets/PlayMaker Custom Actions/uGui/uGuiImageSetSprite.cs:60)
HutongGames.PlayMaker.Actions.uGuiImageSetSprite.OnEnter () (at Assets/PlayMaker Custom Actions/uGui/uGuiImageSetSprite.cs:43)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex)
HutongGames.PlayMaker.FsmState.OnEnter ()
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState)
HutongGames.PlayMaker.Fsm.UpdateStateChanges ()
HutongGames.PlayMaker.Fsm.Start ()
PlayMakerFSM.Start ()

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Resources Load
« Reply #21 on: June 30, 2015, 03:35:51 PM »
Hi,

 are you saving the loaded resource in a FsmObject of the right type ( UnityEngine.Sprite), else the type is lost and becomes generic and can't be injected back where it's supposed to be.

 Bye,

 Jean

phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: Resources Load
« Reply #22 on: June 30, 2015, 05:28:34 PM »
Hi,

 are you saving the loaded resource in a FsmObject of the right type ( UnityEngine.Sprite), else the type is lost and becomes generic and can't be injected back where it's supposed to be.

 Bye,

 Jean

yes I do - the action from the ecosystem btw. drops this error once included in the project (unity 5.1.1f1):

Assets/PlayMaker Custom Actions/Resources/ResourcesLoad.cs(133,64): error CS1061: Type `HutongGames.PlayMaker.FsmVar' does not contain a definition for `ObjectType' and no extension method `ObjectType' of type `HutongGames.PlayMaker.FsmVar' could be found (are you missing a using directive or an assembly reference?)


phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: Resources Load
« Reply #23 on: June 30, 2015, 05:48:18 PM »
Hi,

 are you saving the loaded resource in a FsmObject of the right type ( UnityEngine.Sprite), else the type is lost and becomes generic and can't be injected back where it's supposed to be.

 Bye,

 Jean

I just saw that the first error I posted was from "uGui Set Sprite" - my bad - but the sprite is newer loaded, not sure what I'm doing wrong. The sprite is located directly in "Resources" called "ID_WPN_0001" therefore I try to load "ID_WPN_0001" or did I misunderstand something?

Addition: so far I can follow the Actions Script there is no Sprite Type included at all *wondering*

Another Addition: as for testing  loading a "Texture" works fine :-/
« Last Edit: June 30, 2015, 06:07:38 PM by phannDOTde »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Resources Load
« Reply #24 on: July 01, 2015, 01:43:50 AM »
Hi,

 - a Sprite is not a Texture, both use an image, but Unity will treat them differently, so make sure you select that file and make sure you selected "sprite" as it's type.

 - Can you load it as a texture in an FsmTexture and can you debug it in PlayMaker ( can you verify that indeed the FsmTexture has been feeded with this resource?)

Bye,

 Jean

phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: Resources Load
« Reply #25 on: July 01, 2015, 07:58:02 AM »
Hi,

 - a Sprite is not a Texture, both use an image, but Unity will treat them differently, so make sure you select that file and make sure you selected "sprite" as it's type.

 - Can you load it as a texture in an FsmTexture and can you debug it in PlayMaker ( can you verify that indeed the FsmTexture has been feeded with this resource?)

Bye,

 Jean

Hi Jean

- the source image is set as a sprite in the import settings (see attachment)
- I cross checked yesterday and I can load the same thing (resources load) as an texture and apply it to an raw image component without any issues - if that is what you meant

ps.: I use the actions version from the ecosystem now but I throw out everything from the "Unity 3_5" case in the cs script bc of the error it throws in Unity 5

best
Peter



jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Resources Load
« Reply #26 on: July 02, 2015, 07:28:06 AM »
Hi,

 ok, few things:

-- the ResourcesLoad action works fine in Unity 5, I just tested, can you explain what's wron and why you had to edit it?

-- I validated the principle here, I can load a sprite from a Resources folder using the action "resourcesLoad" and it's fine, the important setup are:

the resourcesLoad MUST be set properly,

type must be "object"
Object Type must be "UnityEngine.Sprite"
StoreAsset must be a FsmObject of type "UnityEngine.Sprite"
 Success and Failure event must be transitions of the state so that you can validate the good execution of the action.


I have attached the test I just did, can you confirm that scene is working for you on your end?

Bye,

 Jean

phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: Resources Load
« Reply #27 on: July 02, 2015, 08:55:30 AM »
Hi,

 ok, few things:

-- the ResourcesLoad action works fine in Unity 5, I just tested, can you explain what's wron and why you had to edit it?

-- I validated the principle here, I can load a sprite from a Resources folder using the action "resourcesLoad" and it's fine, the important setup are:

the resourcesLoad MUST be set properly,

type must be "object"
Object Type must be "UnityEngine.Sprite"
StoreAsset must be a FsmObject of type "UnityEngine.Sprite"
 Success and Failure event must be transitions of the state so that you can validate the good execution of the action.


I have attached the test I just did, can you confirm that scene is working for you on your end?

Bye,

 Jean

Hi Jean

thanks for taking the time.

- As I mentioned in some post before loading "ResourcesLoad.cs" from the Eco system as does loading your sample throws this error:
Quote
Assets/PlayMaker Custom Actions/Resources/ResourcesLoad.cs(133,64): error CS1061: Type `HutongGames.PlayMaker.FsmVar' does not contain a definition for `ObjectType' and no extension method `ObjectType' of type `HutongGames.PlayMaker.FsmVar' could be found (are you missing a using directive or an assembly reference?)

So I figure I remove the UNITY_3_5 exception

Code: [Select]
#if ! UNITY_3_5
System.Type _type = storeAsset.ObjectType;
if (_type == typeof(UnityEngine.Sprite))
{
/* Can't find a way to make a reusable code for All types...
FsmObject _target= this.Fsm.Variables.GetFsmObject(storeAsset.variableName);
// _target.Value = this.LoadResourceByType<_type>(assetPath.Value);

var mi = typeof(ResourcesLoad).GetMethod("LoadResourceByType");
var fooRef = mi.MakeGenericMethod(_type);
_target.Value = (Object)fooRef.Invoke(new ResourcesLoad(), new object[] { assetPath.Value });
*/


UnityEngine.Sprite _sprite = (UnityEngine.Sprite)Resources.Load(assetPath.Value,typeof(UnityEngine.Sprite));
if (_sprite==null)
{
return false;
}else{
FsmObject _target= this.Fsm.Variables.GetFsmObject(storeAsset.variableName);
_target.Value = _sprite;
return true;
}
}
if (_type == typeof(AudioClip))
{
AudioClip audioClip = (AudioClip)Resources.Load(assetPath.Value,typeof(AudioClip));
if (audioClip==null)
{
return false;
}else{
FsmObject _target= this.Fsm.Variables.GetFsmObject(storeAsset.variableName);
_target.Value = audioClip;
return true;
}
}
#else
AudioClip audioClip = (AudioClip)Resources.Load(assetPath.Value,typeof(AudioClip));
if (audioClip==null)
{
return false;
}else{
FsmObject _target= this.Fsm.Variables.GetFsmObject(storeAsset.variableName);
_target.Value = audioClip;
return true;
}
#endif

As for your sample scene, loading the scene into my project and opening it all parameters of the FSM state are gone (maybe an version issue or bc of the modified Action?) - meaning I have to reassign all of them to the Resource Load Action. Once done I get the same result - the Action ends with "OK" but the Variable Object.Sprite is empty :-/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Resources Load
« Reply #28 on: July 08, 2015, 08:04:33 AM »
Hi,

 I haven't touched the public interface, so you should not loose variables assignment, I am confused as to what happens in your case.

are you running on Unity 3.5 and with what version of PlayMaker?

I'll need a clear repro case, cause my tests here shows normal behavior.

Bye,

 Jean

phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: Resources Load
« Reply #29 on: July 13, 2015, 06:49:13 AM »
Hi,

 I haven't touched the public interface, so you should not loose variables assignment, I am confused as to what happens in your case.

are you running on Unity 3.5 and with what version of PlayMaker?

I'll need a clear repro case, cause my tests here shows normal behavior.

Bye,

 Jean

Hi Jean
I work with Unity 5.1.1f1 and PM 1.7.8.3 plus I downloaded the "Load Ressources" Action from the Ecosystem. Friend of mine verified the issue and mentioned it might be related to unity auto updating the Actions Script (?)

Best
Peter