playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Deek

Pages: [1] 2 3 ... 6
1
Playmaker Announcements / Re: PlayMaker 1.8.5 LateUpdate handling change
« on: December 30, 2017, 02:18:38 PM »
I went through my scripts searching for every instance of OnLateUpdate() to make sure they are up-to-date after this change (luckily quite easy with VS2017) and found that (unlike most PlayMaker and custom actions) the following actions aren't updated with the OnPreProcess()-prerequisite yet:

PlayMaker Actions (1.8.5):
"ArrayForEach"

Custom Actions:
"iTweenRotateUpdate2"
"TorqueLookRotation"

For the iTween one you'd need to add:
Code: [Select]
public override void OnPreprocess()
{
    if(updateCall == PlayMakerUpdateCallType.FixedUpdate)
    {
        Fsm.HandleFixedUpdate = true;
    }

    #if PLAYMAKER_1_8_5_OR_NEWER
    if(updateCall == PlayMakerUpdateCallType.LateUpdate)
    {
        Fsm.HandleLateUpdate = true;
    }
#endif
}

For every other action the following suffices:
Code: [Select]
public override void OnPreprocess()
{
    #if PLAYMAKER_1_8_5_OR_NEWER
    Fsm.HandleLateUpdate = true;
    #endif
}

You might want to delete this (my) post after updating those actions to keep this topic clean or notify me to do so.

2
Playmaker Help / Re: API FsmVar get/set 'Category' and get 'Used' count
« on: December 27, 2017, 07:16:19 AM »
For the categories you need to get the reference to your desired FSM (or iterate through all available FSMs by using Fsm.FsmList or Fsm.SortedFsmList). Of course you also need the PlayMaker using directive:
Code: [Select]
using HutongGames.PlayMaker;and from there on you can get all variables and in there all categories, like so:
Code: [Select]
yourFSM.Variables.CategoriesThis holds an array of all categories in that FSM (the first entry is empty, because it's the default category where all unsorted variables land), which you can get or set (though I couldn't find how to set the category of single fsm-variables).

For reference, here is how I get a list of all categories from a specific FSM in my own debug window:
Code: [Select]
string[] allCategories = activeFSM.Variables.Categories;
for(int i = 0; i < allCategories.Length; i++)
{
    //skip empty categories to only display relevant ones
    if(allCategories[i] == "" || allCategories[i] == null)
    {
continue;
    }
    GUILayout.Label("Category " + i + ": " + allCategories[i]);
}

Unfortunately, I also couldn't figure out how to get the used-count of each variable and I think it only gets calculated inside the PlayMaker Editor window script or somewhere else, but I might be wrong. There could be something in other directives like HutongGames.Utility or a helper function nested inside Fsm.[...], but I haven't found anything related yet.

3
Playmaker Help / Re: Does Playmaker has Cache or something?
« on: December 27, 2017, 06:32:14 AM »
Do those still persists after you pressed the 'Clear' button in the console window or after restarting Unity?

Usually those types of warnings are only messages/notifications that are there to inform the end user.
If they don't stay there and you don't need these variables anyway, you should be good to go.
If they do, you might want to copy one of those errors or make a screenshot of them and post them here.

It could be that the missing variables are still referenced in some actions inside the FSM they were previously in, though it should also show related errors in the Error Check window (in the PlayMaker Editor at the bottom left). Then you would have to go through them and change the linked variables.

4
Playmaker Help / Re: Compare colours
« on: December 22, 2017, 04:46:13 PM »
Because I thought this would be a good idea for an action, I made one that is comprehensive enough so that you can specify how many colors should be compared to one another and what parts (r, g, b, a, or any combination between them).
With it you can send single events on matching occurrences or save as a bool, if at least one color matched the specified part of the main color.

Even though you already created a small fsm that handles your requirements, you might still want to use my action to cut down the logic into one action.
I'll probably put it onto the ecosystem soon enough, but for now you can find it in the attachments to this post.

5
Playmaker Help / Re: "Send event" followed by "Mouse Pick Event"
« on: December 19, 2017, 12:21:38 PM »
The problem doesn't lie within the "Send Event" action (so you can ignore that one), but with how the "Mouse Pick Event" functions: It only checks where your mouse is currently at and sets that in relation to the specified GameObject.
If the raycast that gets shot from your current mouse position hits a collider/trigger on that GameObject, it fires the 'Mouse Over' Event, in any other case it fires 'Mouse Off' (the 'Mouse Down' and 'Mouse Up' events can also only fire when the mouse is currently over that GO).
It fires 'Mouse Off' whenever it can't detect the GameObject, which can be caused by several things:
  • the 'Ray Distance' is too small / the GameObject too far away (unlikely)
  • the targeted GameObject doesn't contain a collider or rigidbody
  • you need to specify the layer of the targeted GameObject in the 'Layer Mask'
So you should really only use the 'Mouse Off' event option when you are certain that the mouse is currently over the desired GameObject and want to detect if it moved away from it.

6
Feature Requests / Re: HideInInspector-Attribute for custom actions
« on: December 17, 2017, 12:50:54 PM »
I created this request just before learning about
Code: [Select]
EditField("<variablename>"); with which you can draw single fields in a custom inspector. So there's no real need for that HideInAction attribute.

By using standard variables you would lose the ability to set the fields to none if you want the variable to be an FsmVariable, and I don't think you can access private variables from the inspector (at least I tried it back then, though with FsmVariables), but thanks anyway.

7
Share New Actions / Re: Authoring Custom Actions
« on: December 16, 2017, 08:55:27 AM »
That would be very neat and there seem to be various ways to create/generate c# code at runtime, like  CodeDOM, Roslyn, T4 Text Templates (apparently not supported by Unity), or just having several static classes/dlls that get integrated when needed, though it seems a bit over-ambitious and quite the time sucker.
But if you're determined to do this, I would be absolutely looking forward to it and also interested in seeing your progress on this (you might lead a little dev diary in the "Work In Progress..."-section or somewhere else, where you could also get feedback from others on what to improve or can ask for help when you get stuck somewhere).

GUI-wise it shouldn't prove much of a problem, but I see a few more other possible obstacles on that endeavour:
- in actions you only see the variables, not the functionality behind it, so you would need two ways to customize, one for adding variables and one for adding the functionality behind it
- the code blocks would have to interact with each others flawlessly, making it also difficult to add to them, as that could break functionality on other parts, and since they get added at runtime and likely are supposed to be combined with any other code block it makes debugging even more difficult

Just trying to show some difficulties that you could encouter, but you should definitely try it.

8
Feature Requests / HideInInspector-Attribute for custom actions
« on: December 15, 2017, 08:53:09 AM »
It would be great if the [HideInInspector] attribute could also work on custom actions, since it doesn't seem to do anything on variables and it would be helpful when creating custom inspectors to hide certain fields (as I'm also not friends with automated properties).
If you'd do create an extra attribute for that, might as well call it "HideInAction" to differentiate.

9
Share New Actions / Re: Authoring Custom Actions
« on: December 15, 2017, 08:09:46 AM »
I also always copied over content from other actions that served a similar purpose, but that isn't the best coding habit and could lead to taking over bugs that one doesn't notice at first.
That's why I thought it would be good to have a somewhat blank slate in terms of functionality when creating a new action.

If you do create a more extensive wizard and are open to suggestions, I'd suggest having the option to add any amount of FsmVariables with the ability to choose its type, adding a tooltip and specify if it's required. Having at least one variable would also create the Reset() method that gets feeded with a default value for the defined variables (this I can imagine to be more on the difficult sides to implement).

10
Share New Actions / Re: Authoring Custom Actions
« on: December 15, 2017, 07:13:39 AM »
Templates for creating custom actions
As this seems to be the best place to share them and the Custom Action Wizard still creates pretty lagluster starting points, here are some templates (not to be confused with FSM-Templates) for writing custom actions, that contain pretty much everything you need to start off when creating a new custom action.

File-Description & -Links:
  • Template.cs - The minimum to create a new action
  • TemplateAdvanced.cs - Derives from FsmStateActionAdvanced to automatically supply the option to choose an update type and adds the required comments that would be needed to share the action on the Ecosystem (you would still need access to the appropriate repository to commit the action to the Ecosystem)
  • Editor\TemplateInspector.cs - If you want to change the look and functionality of an action, you can create a custom inspector with this (needs to be in a folder called "Editor" anywhere in your Assets folder, preferably near your base action)
    Note: Remember that any Editor-Script cannot be executed in your build, so these are mainly for added functionality when the user sets up the action. That's why you also have to reference variables from the base script, because Unity only saves the values of those during runtime.
  • ExampleOverview.cs - A collection of further userful examples on things like compound arrays, enums and attributes to modify/style actions

Instructions:   
  • Wherever you see the word "Template" in them, you should replace it with the name of your custom action.
  • You should change the ActionCategory to something that fits your action type or give it an own name if none of the available ones are fitting.
  • When creating a new variable, just copy over the tooltip and variable declaration of one that is already there and only copy the "[RequiredField]" attribute if that variable really needs to be set from the user of your action.
Previews:






Even though the afore-mentioned wiki entry already contains a good overview on how to create certain custom action fields and its process, it doesn't provide a fast way of creating a new one like copying these templates over.

If you have suggestions on what should or shouldn't be in there, let me know.

Edit:
|16.12.17|
- Optimized TemplateInspector so that it only gets the reference to the action in OnEnable() instead of OnGUI() and added example on how to only draw single fields from the base script instead of drawing the whole inspector
- Added additional note to the TemplateInspector description
|23.12.17|
- Added the ExampleOverview and moved a few lines from TemplateAdvanced to that
|31.12.17|
- Added further OnPreprocess examples to ExampleOverview
- Removed the attachments, the in-line ExampleOverview-Preview and changed the script location from Gist to my main GitHub repository, so that I only have to update the scripts in one location when I change something
- reverted reference to action back to OnGUI() in TemplateInspector, because of a PlayMaker bug where it applied the cached action-reference to every open instance of that action, meaning that when the action was also selected in the Action Browser and I tried to get the action's owner, it constantly returned a Null-Reference-Exception because it also tried to get the owner of the action in the Asset Browser; also when two of the same actions where in one state and when changing values in one of them, it also applied them to the other instance (at least the values from the custom inspector) | having the action reference in OnGUI() works flawlessly now

11
Share New Actions / Re: ...just another big Custom Action collection
« on: December 12, 2017, 11:14:08 AM »
@craigz
Thanks for your kind words.
Yep, the line that causes the error was still in the updated version, even though I could have sworn that I removed it. Anyway, NOW there is the fixed version in the links and in this attachment, sorry for that.  ::)

@djaydino
The fact that I'm currently using GitHub to share these actions should show that I at least have the basic understand on how to handle repositories. :)

Though, for the u5 repo, does it necessarily need to be Unity 5.6.4, because I currently use 5.6.1f1.

Also since I've seen you guys trying to explain the process on several posts individually, why not make a sticky in the 'Share New Actions' section with a more exhaustive and universal explanation which you can then reference/link to when you need to explain it to someone again.
For example, this post on that topic also reveals additional info that would be worth mentioning:


And it might be redundant to rewrite that every time; just a suggestion.

12
Playmaker Help / Re: GameDataEditor - Help needed with 'GDE Create Item'
« on: December 10, 2017, 03:21:05 PM »
Nevermind, the error was on my part. I got the same problems when testing the action myself, even though it weirdly didn't cause any trouble when creating the action.

The problems mainly occured because I wrote a custom inspector for that action, which showed all available Schemas and Item Names, but because there were several problems with writing those values to the action and because it caused lag spikes when loading all data, I removed that custom inspector and re-worked the action, which means you have to delete the "GDECreateItemInspector.cs" file and replace the "GDECreateItem.cs" with the one from the attachments or the initial post.

Sorry for that, but it should work now and I tested it more thoroughly this time :P

13
General Discussion / Re: How to active obj after it's inactive already?
« on: December 10, 2017, 06:37:51 AM »
On the action "Activate Game Object" you have a bool (toggle button) called "Activate" which says if the GameObject should be activated or not. Just call this action again later when you want the GameObject to be activated by ticking that "Activate" button.


14
Playmaker Help / Re: How to Get "Audio Clip" from Audio Source
« on: December 10, 2017, 06:31:13 AM »
You could use Get Property on the AudioSource instead of Get Component on the GameObject but a better approach is to only have one AudioSource, use my "Select Random Audio Clip" action from the attachments (with which you can also set the weight a.k.a. with what chance a specific Audio Clip will be picked) and then use that variable in "Set Audio Clip" or "Audio Play".

Make sure that your AudioSource is near the AudioListener (usually on your Main Camera), because otherwise you won't hear anything.

15
Share New Actions / Re: ...just another big Custom Action collection
« on: December 10, 2017, 04:35:31 AM »
The updated version is available on both ends.
The direct download links lag a bit behind since I usually only sync my changes at the end of the day or the morning after, but I will likely soon have a better way of providing these (or maybe push these to the Ecosystem).

For your convenience I put the updated script as an attachment to this post, so you don't have to skim through the folders again ;)

Pages: [1] 2 3 ... 6