playMaker

Author Topic: Have to restart Unity to make some playmaker stuff work as it should  (Read 297 times)

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
This is quite worrying and I am pretty sure I wasn't doing anything wrong as both cases are so simple:

1.
I was working on a uGUI and I made the FSM template work properly on one button and then copied over the
- playmaker uGUI component proxy (was set to target Use Owner)
- and the template FSM to other 3 similar buttons
and tested it and found the bug that when I pressed one of the buttons another one was also pressed at the same time. Restarted several times with same result.
I was like ??? this should just work, what could be wrong? The buttons weren't overlapping of course.
I changed the target in the component proxy from Use Owner to the specific game object and it worked well that way.
Restarted Unity and set back the component proxys to target the Use Owner and it all worked perfectly and keeps on working since then.

I am pretty sure it just needed a Unity restart.
Why is this?
How can I know when I need to restart Unity to get such things working properly so I don't waste time debugging stuff that should just work.

2.
Just now I found that the
Convert Formatted String To Float and the Convert String To Float
just does not work.
I looked at the state when it was running and the string value was there, but all the float results were 0.
I tried many different number styles but all resulted in 0 in various float variables and even the simple Convert String To Float was not converting 56.00 to nothing, the resulting float was 0.

Restated Unity and all works, perfectly.

Why is this?
How can I know when I need to restart Unity to get such things working properly so I don't waste time debugging stuff that should just work.

Has anybody else experienced such behavior?

Br,
szomaza

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #1 on: October 30, 2017, 02:14:52 AM »
:-) And it continues:

I duplicated the scene inside Unity, opened the new one and the string to float conversions don't work again.
Unity restart, and they MAGICALLY work again properly.

I am not doing anything just restarting Unity and that makes the actions in a state work again.

???

Is something getting messed up? Should I reimport all assets?

Br,
szomaza

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #2 on: October 30, 2017, 02:58:36 AM »
It's getting funnier. Please see attached image.

Any idea what I should try?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2280
    • View Profile
    • jinxtergames
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #3 on: October 30, 2017, 12:57:06 PM »
Hi,
What unity / playmaker version are you using.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #4 on: October 30, 2017, 10:53:10 PM »
Hi,

 using undo isn't a good idea here to get a real idea of what was happening, prefer switching on DebugFlow in the Fsm property and run the fsm then pause and step back, you'll have the real values.

 This is likely a mess with your logic system and something is setting these variables either from another fsm or via a flow of states and transition you did not expect. I never had this issue.

If you can repro this consistently with clearly defined steps, pm me with the projects and I'll repro locally and see what it could be.

bye,

 Jean

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #5 on: October 31, 2017, 02:54:25 AM »
I have Unity 2017.1.1f1 and Playmaker 1.8.5.f8 but it's not a problem with those, as I created a new project and of course the same things work there perfectly.

In the project where I am getting this behavior I have created new variables, so I am surely not overwriting them from anywhere else, but still get the same problem.
« Last Edit: October 31, 2017, 04:10:55 AM by szomaza »

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #6 on: October 31, 2017, 04:18:29 AM »
OK, finally making some progress.
I noticed that there are 2 errors at runtime:

Code: [Select]
FormatException: Input string was not in the correct format
System.Int32.Parse (System.String s) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Int32.cs:629)
HutongGames.PlayMaker.Actions.ConvertStringToInt.DoConvertStringToInt () (at Assets/PlayMaker/Actions/ConvertStringToInt.cs:46)
HutongGames.PlayMaker.Actions.ConvertStringToInt.OnEnter () (at Assets/PlayMaker/Actions/ConvertStringToInt.cs:33)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:199)
HutongGames.PlayMaker.FsmState.OnEnter () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:169)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2670)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2628)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2556)
HutongGames.PlayMaker.Fsm.DoTransition (HutongGames.PlayMaker.FsmTransition transition, Boolean isGlobal) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2595)
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2178)
HutongGames.PlayMaker.Fsm.SendEventToFsmOnGameObject (UnityEngine.GameObject gameObject, System.String fsmName, HutongGames.PlayMaker.FsmEvent fsmEvent) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2535)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2302)
HutongGames.PlayMaker.Actions.SendEvent.OnEnter () (at Assets/PlayMaker/Actions/SendEvent.cs:42)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:199)
HutongGames.PlayMaker.FsmState.OnEnter () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:169)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2670)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2628)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2556)
HutongGames.PlayMaker.Fsm.DoTransition (HutongGames.PlayMaker.FsmTransition transition, Boolean isGlobal) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2595)
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2178)
HutongGames.PlayMaker.Fsm.SendEventToFsmOnGameObject (UnityEngine.GameObject gameObject, System.String fsmName, HutongGames.PlayMaker.FsmEvent fsmEvent) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2535)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2302)
HutongGames.PlayMaker.Actions.SendEvent.OnEnter () (at Assets/PlayMaker/Actions/SendEvent.cs:42)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:199)
HutongGames.PlayMaker.FsmState.OnEnter () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:169)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2670)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2628)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2556)
HutongGames.PlayMaker.Fsm.DoTransition (HutongGames.PlayMaker.FsmTransition transition, Boolean isGlobal) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2595)
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2178)
HutongGames.PlayMaker.Fsm.SendEventToFsmOnGameObject (UnityEngine.GameObject gameObject, System.String fsmName, HutongGames.PlayMaker.FsmEvent fsmEvent) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2535)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2302)
HutongGames.PlayMaker.Actions.SendEvent.OnEnter () (at Assets/PlayMaker/Actions/SendEvent.cs:42)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:199)
HutongGames.PlayMaker.FsmState.OnEnter () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:169)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2670)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2628)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2556)
HutongGames.PlayMaker.Fsm.DoTransition (HutongGames.PlayMaker.FsmTransition transition, Boolean isGlobal) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2595)
HutongGames.PlayMaker.Fsm.ProcessEvent (HutongGames.PlayMaker.FsmEvent fsmEvent, HutongGames.PlayMaker.FsmEventData eventData) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2178)
HutongGames.PlayMaker.Fsm.SendEventToFsmOnGameObject (UnityEngine.GameObject gameObject, System.String fsmName, HutongGames.PlayMaker.FsmEvent fsmEvent) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2535)
HutongGames.PlayMaker.Fsm.Event (HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2302)
HutongGames.PlayMaker.Actions.SendEvent.OnEnter () (at Assets/PlayMaker/Actions/SendEvent.cs:42)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:199)
HutongGames.PlayMaker.FsmState.OnEnter () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:169)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2670)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2628)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2556)
HutongGames.PlayMaker.Fsm.UpdateState (HutongGames.PlayMaker.FsmState state) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2686)
HutongGames.PlayMaker.Fsm.Update () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1920)
PlayMakerFSM.Update () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:532)

Code: [Select]
FormatException: Input string was not in the correct format
System.Int32.Parse (System.String s) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Int32.cs:629)
HutongGames.PlayMaker.Actions.ConvertStringToInt.DoConvertStringToInt () (at Assets/PlayMaker/Actions/ConvertStringToInt.cs:46)
HutongGames.PlayMaker.Actions.ConvertStringToInt.OnEnter () (at Assets/PlayMaker/Actions/ConvertStringToInt.cs:33)
HutongGames.PlayMaker.FsmState.ActivateActions (Int32 startIndex) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:199)
HutongGames.PlayMaker.FsmState.OnEnter () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:169)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2670)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2628)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2556)
HutongGames.PlayMaker.Fsm.UpdateState (HutongGames.PlayMaker.FsmState state) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2686)
HutongGames.PlayMaker.Fsm.Update () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1920)
PlayMakerFSM.Update () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:532)

Every time I restart Unity those actions converting strings to floats work the 1st time I play the scene, but stop working after that when I play it again, so I guess these errors mess something up.

Clicking the errors it points to 2 different game objects.
If after restarting Unity I disable those, then I don't get these errors anymore and other things keep working no matter how many times I play the scene.

I'll try to figure out what is the problem there... and get rid of those errors.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2280
    • View Profile
    • jinxtergames
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #7 on: October 31, 2017, 12:12:54 PM »
Hi,
From what i can see on this error it is talking about a ConvertStringToInt action and
on the 1st post you where talking about string to float conversions.

Also :
Code: [Select]
FormatException: Input string was not in the correct formatmeans that there is a wrong format (string/int/float are formats) :)

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #8 on: November 02, 2017, 09:11:33 AM »
Good news I narrowed it down and managed to reproduce this in a fresh project with just a few actions.

This is how it goes:
1. When playing the scene for the 1st time there is no error and the "string to float" works nicely.
2. Then Stop and Play again to get the error and the float result is 0 now, not working.
3. The project has to be reloaded to be able to run without error again (for the 1st time)

Before the state that should be doing the "String to Float" conversion I have another state with 2 actions:
Get Day Of Week
Get Number Of Days In Month

If this date manipulating state is excluded from the FSM then the float gives proper result every time no matter how many time the scene is played, so I guess those are causing the whole problem.

LOL, I made these actions some time ago:
http://hutonggames.com/playmakerforum/index.php?topic=12203.0

And they have been working properly since and keep on working even when the "string to float" convert stops, but I have no idea what is going on, how can these actions break the "string to float" from working???

Can I send you this test project or could you check the code of those 2 actions on the above link?
Maybe there is something totally wrong with them.

Strange thing is they have been working for a long time, and anyway, how can they prevent the "string to float" from working?
I did update the project to a fresh Unity and Playmaker, so maybe those date actions are doing something that should not be done anymore?

Thanks in advance,
szomaza

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #9 on: November 02, 2017, 01:41:26 PM »
Hi,

 yes, pm me with the project, I'll have a look, sounds odd indeed.

 bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #10 on: November 08, 2017, 01:48:37 AM »
Hi,

 ok, it's the dayOftheWeek action that is messing things up.

you have to comment the thread setting lines, so that it doesn't touch the computer current culture.

else, if you did that in purpose, can you explain the logic behind doing so and why your other code did not work?


Code: [Select]
        public override void OnEnter()
        {
           // CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
          //  Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            //DateTime dateValue = new DateTime(year.Value, month.Value, day.Value);
            //dayOfWeek.Value = dateValue.ToString("dddd", new CultureInfo("en-US"));

            DateTime dateValue = new DateTime(year.Value, month.Value, day.Value);
            dayOfWeek.Value = dateValue.ToString("dddd");
           
         //   Thread.CurrentThread.CurrentCulture = originalCulture;

            Finish();
        }


szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #11 on: November 10, 2017, 03:50:51 AM »
Thank you a bunch for checking!

If I remember correctly ... I guess I needed to change it to "en-US" for the time while it gets the day of the week to make sure that no matter what Culture the player's phone is set to, I would get proper "Monday, Tuesday, ..." returned.

Yes, it's explained here:
http://hutonggames.com/playmakerforum/index.php?topic=12203.0
And also where I got it from:
https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-extract-the-day-of-the-week-from-a-specific-date

I am setting it back to the original culture after that.
Why is this a problem?

Well anyway is there a better way to always get the english names of the days as a result without setting the Culture?  No matter what Culture the Players device is set to?

Thanks in advance,
szomaza

edit: Also could you please explain how is that action (dayOftheWeek) able to to run once perfectly and then when playing subsequent times cause other errors, like for example the StringToFloat action to not work?

One new thing I noticed is that random events in various FSMs are being turned to global events. (the checkbox of internal event gets ticked)
This is quite worrying that because of this error various things in FSMs can get changed. I am not sure now how many things might have got messed up and I am afraid to keep working.  :-)
How can these happen because of a buggy? script?

Please help! Thanks!
« Last Edit: November 10, 2017, 12:29:06 PM by szomaza »

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #12 on: November 14, 2017, 08:56:12 AM »
Hi All,

Unfortunately I can not solve this myself.
As far as I know this simple action which gives back the day of the week (Monday, Tuesday, etc.) as a string, should (and has been working for more than a year) work properly.

I am not sure what can be the problem with it now and how is it even possible to mess up other playmaker actions.

If anybody can and has some time please help me out.
I have an example project I could PM send you (it contains playmaker so I won't share it here.)
or just help me to tune the action:

GetDayOfWeek.cs
http://hutonggames.com/playmakerforum/index.php?topic=12203.0

It should simply do: "Returns day of the week (Monday, Tuesday, ...) for the specified year, month, day."

Jean writes the problem comes from the lines messing with "current culture".
This was required to change it to "en-US" for the time while it gets the day of the week to make sure that no matter what Culture the player's phone is set to, I would get proper "Monday, Tuesday, ..." returned. (I use that later, switching by the string value.)

Is there a better way to always get the english names of the days as a result without setting the Culture?  No matter what Culture the Players device is set to?
Or just 1 , 2 , 3 ... 7  for Monday to Sunday if the english names of the days is too much to ask for?

I got the code from:
https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-extract-the-day-of-the-week-from-a-specific-date

Thanks in advance!
szomaza

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #13 on: November 16, 2017, 11:39:08 PM »
Hi Jean!

You wrote:
" it's the dayOftheWeek action that is messing things up.
you have to comment the thread setting lines, so that it doesn't touch the computer current culture."

1.
Please explain why this is a problem and how this can cause other perfectly good playmaker actions (e.g. convert string to float) to not work.
The Microsoft doc seems quite confident that their code should be OK:
https://docs.microsoft.com/en-us/dotnet/standard/base-types/how-to-extract-the-day-of-the-week-from-a-specific-date

2.
Is there a better / working way to get the day of the week for a specific date.
(In English, no matter what culture setting the players device is set to.)

Thanks in advance,
szomaza

szomaza

  • Full Member
  • ***
  • Posts: 172
    • View Profile
Re: Have to restart Unity to make some playmaker stuff work as it should
« Reply #14 on: November 17, 2017, 12:47:42 PM »
Looks like I'll have to learn to code in the end.  :-)

I modified the script to give back the number of the day instead of the name of it, because in that case it does not need the culture setting.

DateTime dateValue = new DateTime(year.Value, month.Value, day.Value);
dayOfWeek.Value = ((int) dateValue.DayOfWeek;

One thing to pay attention to in this case is:
https://docs.microsoft.com/en-us/dotnet/api/system.dayofweek?view=netframework-4.7.1
"Sunday to Saturday. If cast to an integer, its value ranges from zero (which indicates Sunday) to six (which indicates Saturday)."

Seems to work so far...