playMaker

Author Topic: Argument exception : need help [SOLVED]  (Read 3409 times)

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Argument exception : need help [SOLVED]
« on: August 27, 2018, 09:22:16 AM »
Hello,

i have been working on my Post processing actions, which where working nice before this little update...

i replaced my first variables  to get the PostProcessing Profile and Volume by an FSMOwner

The code is absolutely perfect and doesn't give error.

But when i enter the game, it returns me this error:

ArgumentException: GetComponent requires that the requested component 'PostProcessProfile' derives from MonoBehaviour or Component or is an interface.
UnityEngine.GameObject.GetComponent[PostProcessProfile] () (at C:/buildslave/unity/build/Runtime/Export/GameObject.bindings.cs:28)
HutongGames.PlayMaker.Actions.PostProcessingDepthOfField.SetDoF () (at Assets/PlayMaker/Actions/Post Processing/PostProcessingDepthOfField.cs:95)
HutongGames.PlayMaker.Actions.PostProcessingDepthOfField.OnEnter () (at Assets/PlayMaker/Actions/Post Processing/PostProcessingDepthOfField.cs:76)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:205)
HutongGames.PlayMaker.FsmState.OnEnter () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:175)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2767)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2714)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2642)
HutongGames.PlayMaker.Fsm.Start () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1925)
PlayMakerFSM.Start () (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:548)

here is the parts of code for my action:

Code: [Select]
[ActionCategory("Post Processing Stack V2")]
[Tooltip("Modify Depth of Field during runtime.")]
public class PostProcessingDepthOfField : FsmStateAction
{
#region public variables
[RequiredField]
[ObjectType(typeof(PostProcessVolume))]
[Tooltip("Post Processing Profile to modify")]
public FsmOwnerDefault ObjectVolume;

[RequiredField]
[ObjectType(typeof(PostProcessProfile))]
[Tooltip("Post Processing Profile to modify")]
public FsmOwnerDefault ObjectProfile;

...
                if(ObjectVolume !=null)
{
var go = Fsm.GetOwnerDefaultTarget(ObjectVolume);
var UsedVolume = go.GetComponent<PostProcessVolume>();
var UsedProfile = go.GetComponent<PostProcessProfile>();
UsedVolume.profile.TryGetSettings(out DofLayer);

so i tryed to replace FsmStateAction by Monobehaviour, and got some changes to make around void, and finally got stuck with another error message on the Fsm.GetOwnerDefaultTarget();

An object reference is required for the non-static field, method, or property 'Fsm.GetOwnerDefaultTarget(FsmOwnerDefault)'

« Last Edit: August 29, 2018, 03:28:05 AM by blackant »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Argument exception : need help
« Reply #1 on: August 28, 2018, 04:08:54 AM »
Hi,

 it's because the PostProcessProfile is a scriptableObject asset not a component, so you need to use an FsmObject, instead of FsmGameObject or FsmOwnerDefault.

 Bye,

 Jean

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: Argument exception : need help
« Reply #2 on: August 28, 2018, 01:53:36 PM »
haaa yes of course, this is the file we drop inside the postprocessing volume !
i understand better now ^^

thanks ;D

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: Argument exception : need help
« Reply #3 on: August 28, 2018, 02:52:22 PM »
Well, it helped me for the first step around it, but i'm confronting another problem:

UsedVolume.profile = ObjectProfile.Value ;

return this error:

Assets/Blackant Master Studio/Playmaker PostProcessing StackV2/PostProcessingVolumeParameters.cs(55,40): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.Rendering.PostProcessing.PostProcessProfile'. An explicit conversion exists (are you missing a cast?)

the thing is that i can set my variable directly like that to get it to work:
public postProcessingProfile ObjectProfile; but by this method i can't use the strength of playmaker...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Argument exception : need help
« Reply #4 on: August 29, 2018, 02:31:13 AM »
Hi,

 you need to cast properly the objectProfile.Value to PostProcessProfile

something like that:
Code: [Select]
UsedVolume.profile = ObjectProfile.Value as PostProcessProfile;
Bye,

 Jean

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: Argument exception : need help
« Reply #5 on: August 29, 2018, 03:27:47 AM »
was super simple in fact. thanks i'm learning a lot.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Argument exception : need help [SOLVED]
« Reply #6 on: August 29, 2018, 04:30:11 AM »
Hi,

 yes :) it's good that you make this effort to learn scripting and ask questions along the way, this is the best way to move forward.

 Bye,

 Jean