Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: twiggyash on March 30, 2016, 08:03:22 AM

Title: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on March 30, 2016, 08:03:22 AM
Hi, I'm using playmaker on Unity 4.7 and my project is full of Set/Get Properties no more allowed in Unity 5.x . Is there a way to automatically convert these in the new format? Cause doing it manually is impossible for me, is like restart the project from beginning. Hope in a solution.

Thank you very much for help!
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: dudebxl on March 30, 2016, 09:04:27 AM
What do you mean it is not allowed? I am in 5.2 and I am still using get/set.. are you sure about this?
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on March 30, 2016, 10:00:59 AM
I mean this: "Unity 5 removed properties that allowed you to target common components on a GameObject (e.g., guiTexture, renderer, rigidbody...). If you targeted these properties with Get Property or Set Property actions the target no longer exists and you will need to re-target the action. Instead, you should target the component directly - drag the Component into the Target Object field NOT the GameObject."
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: Alex Chouls on March 30, 2016, 11:09:38 AM
Let me look into this, there might be a way to use the action's error check method to automatically upgrade the action...
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on March 30, 2016, 11:20:38 AM
Would be great!!! Thank you a lot for help!
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: Alex Chouls on March 31, 2016, 02:13:59 PM
Please try the attached script. It modifies PlayMaker > Tools > Update All FSMs in Build.

BACKUP your project first and treat this script as a BETA!!

This script updates any Get Property or Set Property actions on a GameObject that targets the properties removed in Unity 5+.

How it works:

- It loops through all scenes in Build Settings.
- It finds all Get Property and Set Property actions.
- If the property was removed in Unity 5:
  - It replaces Target Object with a direct reference to the component.
  - It modifies the Property Path to be relative to that component.

Limitations:

- It does NOT work on Templates. Automatically updating a template would involve adding Get Component actions and variables. This is more invasive than modifying the Get/Set Property actions. If you really need a solution for templates we could explore a modified version of the Get/Set Property actions that would detect the removed properties and use GetComponent, but performance would be slower than updating the FSMs manually.
- The targeted components have to exist on the GameObject when you run the update script. The script uses GetComponent to update the actions. If you add the components at runtime you will need to add a GetComponent action.

Please post your results and any problems you run into.
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on April 01, 2016, 09:30:09 PM
Thank you very much for support! I'll try this as soon as possible and I'll let you know the results. Thanks again!
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on April 04, 2016, 09:50:15 PM
Please try the attached script. It modifies PlayMaker > Tools > Update All FSMs in Build.

BACKUP your project first and treat this script as a BETA!!

This script updates any Get Property or Set Property actions on a GameObject that targets the properties removed in Unity 5+.

How it works:

- It loops through all scenes in Build Settings.
- It finds all Get Property and Set Property actions.
- If the property was removed in Unity 5:
  - It replaces Target Object with a direct reference to the component.
  - It modifies the Property Path to be relative to that component.

Limitations:

- It does NOT work on Templates. Automatically updating a template would involve adding Get Component actions and variables. This is more invasive than modifying the Get/Set Property actions. If you really need a solution for templates we could explore a modified version of the Get/Set Property actions that would detect the removed properties and use GetComponent, but performance would be slower than updating the FSMs manually.
- The targeted components have to exist on the GameObject when you run the update script. The script uses GetComponent to update the actions. If you add the components at runtime you will need to add a GetComponent action.

Please post your results and any problems you run into.

Hi again, finally tried the script but, after selecting Update all Fsms in Build, in few seconds Unity crashed. Tried more times but it always crashes.

I'm using Unity last version 5.3.4. and Playmaker 1.8.0

Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: Alex Chouls on April 04, 2016, 09:58:31 PM
Can you send me the editor log after the crash?
http://answers.unity3d.com/questions/9739/how-can-i-find-editor-log-file.html
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on April 04, 2016, 11:09:52 PM
Here it is.
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: Alex Chouls on April 05, 2016, 01:44:22 PM
Thanks! It looks like Unity is crashing on an Undo in the batch operation, maybe running out of memory. So I've removed the Undo (you can't really undo the batch operation anyway, you'd have to revert to a backup). I've updated the original download. Please give it another go!
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on April 05, 2016, 01:54:49 PM
Thanks! It looks like Unity is crashing on an Undo in the batch operation, maybe running out of memory. So I've removed the Undo (you can't really undo the batch operation anyway, you'd have to revert to a backup). I've updated the original download. Please give it another go!
Hi :) this time when imported the console gives me this error:

Assets/PlayMaker/Editor/PlayMakerProjectTools.cs(173,37): error CS0103: The name `SetFsmDirty' does not exist in the current context
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: Alex Chouls on April 05, 2016, 02:25:15 PM
Sorry about that. Fixed. Please download it again :)
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on April 05, 2016, 04:28:56 PM
Sorry about that. Fixed. Please download it again :)
Tried. Ok, it works quite well with Get/Set actions about GameObjects, but many activate/deactivate render mesh actions doesn't work.
There are problems with particle systems too, none works.
I noticed problems too with skinned meshes; basically when a skinned mesh is child of another, the actions that were about the child skinned mesh, now are changed to the parent skinned mesh.
These are the major issues for what I saw at the moment.

Thank you for your efforts and support.
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: Alex Chouls on April 05, 2016, 07:52:18 PM
Quote
many activate/deactivate render mesh actions doesn't work.
There are problems with particle systems too, none works.
I noticed problems too with skinned meshes;

Which actions are you using in these cases? Can you give me examples?
If you can fix the problems manually let me know how and maybe we can automate it. But I need specific examples...
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on April 05, 2016, 08:07:31 PM
Quote
many activate/deactivate render mesh actions doesn't work.
There are problems with particle systems too, none works.
I noticed problems too with skinned meshes;

Which actions are you using in these cases? Can you give me examples?
If you can fix the problems manually let me know how and maybe we can automate it. But I need specific examples...
Ok, for render mesh enable/disable I used Set property - Render - Enabled;
for system particles I used Set Property - System Particle - Emit;
for nested skinned mesh conflicts is difficult to explain, but in my case I have a character with a mesh for body (skinned mesh) and one separated mesh for hairs (other skinned mesh), I referenced a Get/Set action to hairs mesh and it turned into an action to the parent character. Do not know why.
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: Alex Chouls on April 05, 2016, 10:49:03 PM
Hmmm, the update should fix Renderer and Particle System component references.
Any chance you could build me a scene in 4.x with just the actions that fail?
Title: Re: Automation to substitute Get/Set Properties from Unity 4.x to 5.x
Post by: twiggyash on April 06, 2016, 11:12:20 AM
Hmmm, the update should fix Renderer and Particle System component references.
Any chance you could build me a scene in 4.x with just the actions that fail?
Ok. Let me try do make a little scene with this two issues in Unity 4.7