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.


Topics - looi

Pages: [1]
1
Action Requests / Count Colored Pixels In Textures
« on: June 06, 2019, 10:00:45 AM »
Hello!

I've done a new action. It counts the number of a certain color pixels in a texture. Any changes or suggestions to improve performance or functionality it are more than welcome!

 (Note: part of the code I have taken from https://hutonggames.com/playmakerforum/index.php?topic=11929.0 )

 
Code: [Select]
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("ArrayMaker/ArrayList")]
[Tooltip("Count the number of pixels of a certain color")]
[HelpUrl("http://hutonggames.com/playmakerforum/index.php?topic=11929.0")]

public class CountColoredPixelsInTextures : ArrayListActions
{

[ActionSection("Input")]
public FsmTexture texture;
        public FsmColor colorToCount;

        [RequiredField]
        [UIHint(UIHint.Variable)]
        public FsmInt storeResult;

        [ActionSection("Event")]
[UIHint(UIHint.FsmEvent)]
public FsmEvent doneEvent;
[UIHint(UIHint.FsmEvent)]
[Tooltip("The event if error")]
public FsmEvent failureEvent;

private Color[] pix;
        private Texture2D targetmaskedTexture;
public override void Reset()
{
            storeResult = null;
failureEvent = null;
doneEvent= null;
texture = null;
}

public override void OnEnter()
{

bool noError = false;

if (texture.IsNone){
Debug.LogWarning("<color=#6B8E23ff>No texture. Please review!</color>", this.Owner);
noError = true;
}

targetmaskedTexture = null;
targetmaskedTexture = texture.Value as Texture2D;

try
{
targetmaskedTexture.GetPixel(0, 0);
}
catch(UnityException)
{

Debug.LogWarning("<color=#6B8E23ff>Please enable read/write on texture  </color>"+"[" + texture.Value.name + "]", this.Owner);
noError = true;
}

if (noError == true){
Fsm.Event(failureEvent);
return;
            }
            else {
                storeResult.Value = 0;
                pix = targetmaskedTexture.GetPixels(0);

                for (int i = 0; i < pix.Length; i++)
                {
                    if (colorToCount.Value == pix[i]) {
                        storeResult.Value = storeResult.Value + 1;
                        }
                }
                pix = new Color[0];

            }

Fsm.Event(doneEvent);
            return;
}
}
}

2
Action Requests / ArrayList Get Vertex Positions (world space)
« on: April 10, 2019, 06:25:56 PM »
Hello,

I've modified the action ArrayListGetVertexPositions to obtain the world space points of a mesh vertices instead of local points.

I think it might be usefull to upload it to Ecosystem.

Code: [Select]
// (c) Jean Fabre, 2011-2013 All rights reserved.
// http://www.fabrejean.net

// INSTRUCTIONS
// Drop a PlayMakerArrayList script onto a GameObject, and define a unique name for reference if several PlayMakerArrayList coexists on that GameObject.
// In this Action interface, link that GameObject in "arrayListObject" and input the reference name if defined.
// Note: You can directly reference that GameObject or store it in an Fsm variable or global Fsm variable

// credits: action created by LampRabbit: http://hutonggames.com/playmakerforum/index.php?topic=3982.msg18550#msg18550

using System;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("ArrayMaker/ArrayList")]
[Tooltip("Store mesh vertex positions into an arrayList")]
public class ArrayListGetVertexPositions : ArrayListActions
{

[ActionSection("Set up")]

[RequiredField]
[Tooltip("The gameObject with the PlayMaker ArrayList Proxy component")]
[CheckForComponent(typeof(PlayMakerArrayListProxy))]
public FsmOwnerDefault gameObject;

[Tooltip("Author defined Reference of the PlayMaker ArrayList Proxy component ( necessary if several component coexists on the same GameObject")]
public FsmString reference;


[ActionSection("Source")]

[Tooltip("the GameObject to get the mesh from")]
[CheckForComponent(typeof(MeshFilter))]
public FsmGameObject mesh;



public override void Reset()
{
gameObject = null;
reference = null;
mesh = null;

}


public override void OnEnter()
{
if ( SetUpArrayListProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject),reference.Value) )
getVertexPositions();

Finish();
}


public void getVertexPositions()
{
if (! isProxyValid())
return;

proxy.arrayList.Clear();


GameObject _go = mesh.Value;
if (_go==null)
{
return;
}


MeshFilter _mesh = _go.GetComponent<MeshFilter>();
if (_mesh ==null)
{
return;
}
            proxy.arrayList.Clear();
            for (int i = 0; i < _mesh.mesh.vertices.Length; i++) {
                proxy.arrayList.Add(_mesh.transform.TransformPoint(_mesh.mesh.vertices[i]));
            }

//proxy.arrayList.InsertRange(0,_mesh.mesh.vertices);


}
}
}

3
Action Requests / get File Name From Path[SOLVED]
« on: March 20, 2019, 10:36:36 AM »
Hello!

One request: an action to obtain a filename from a path. I think it should be easy, but I can't do it.

It may use the GetFileName function https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getfilename?redirectedfrom=MSDN&view=netframework-4.7.2#System_IO_Path_GetFileName_System_String_

Code: [Select]
string onlyFileName = System.IO.Path.GetFileName(entirePath);
someone? :D

4
Playmaker Help / Access PlayMakerHashTableProxy from scipt
« on: May 16, 2018, 03:43:08 PM »
Hello!

First of all, I know this is more relative to a C# understanding than PlayMaker itself, even so, I would appreciate your help.

I've filled a playmaker hashtable with all NCS colors with their key names, now I need to access them from a script. I've managed to read all the values, but I cannot convert them to UnityEngine.Color32 to be able to operate them and to do all calculations I want to do with RGB, etc.

Code: [Select]
foreach (DictionaryEntry colorInTheList in NcsList.hashTable) {
     Debug.Log(colorInTheList.Value) //it prints RGBA(0,0,0,0) the color!
     Color32 colorValue = colorInTheList.Value
}

with this code, the console says "error CS0266: Cannot implicitly convert type `object' to `UnityEngine.Color32'. An explicit conversion exists (are you missing a cast?)"

Thank youuu!

5
Playmaker Bug Reporting / I cannot add new Global Variable
« on: December 26, 2017, 11:19:47 AM »
I open the Global Variables window and I click on the input text to create a new global variable, but the cursor just doesn't stay there as always. So, as the cursor is not in the input text, I can't type anything and I can't add the variable.

I have noticed that after doing that, if I try to add a local variable, it happens the same. Before trying to add a new global variable I can add local variables, but after the error, I cannot even create a local variable.

It happens happens whenever I try to create a global variable.

(PS: I have just reported the bug via Editor)

6
Playmaker Bug Reporting / Global variables become inaccesible
« on: June 27, 2016, 02:41:55 AM »
Hello,

I don't know how to describe well this issue, because it is a little strange.
I have a project with a huge list of global variables. I started it with the previous version of Playmaker and I upgrade to the last version and all works... apparently.

Now, when I try to access a global variable from a script, I just doesn't find it. It's correctly written and all is okay, but it doens't find it.

I have to delete the variable and create it again with the same name. Then it works well.

Why is it happening? Maybe I should not update to 1.8.1?  :-\

Thank you!

7
Playmaker Help / Xml Select Nodes by Fsm String
« on: June 17, 2016, 05:25:48 AM »
Hello

I want to parse an XML from a URL and save it in a ArrayList.
I've done the first part, I got the XML with the action WWW Object and I'm saving it in a string.

Then, I want to parse it with the action Xml Select Nodes. I select Source selection: Use Variable. Then, it appears the dropdown list with all my strings, but I can't select any of them.

When I try to select a string from the list, In the Console appears this error:
Code: [Select]
ArgumentException: Object type HutongGames.PlayMaker.FsmString cannot be converted to target type: HutongGames.PlayMaker.FsmEvent
Parameter name: val
System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoField.cs:133)
System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/FieldInfo.cs:150)
HutongGames.PlayMakerEditor.ActionEditor.DoVariableSelection (System.Object userdata) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Editor/Classes/ActionEditor.cs:2826)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, Int32 selected) (at C:/buildslave/unity/build/artifacts/generated/common/editor/GenericMenuBindings.gen.cs:122)

I've searched for this problem and I couldn't find solution here. In this case the problem is not in the variable itself, because I cannot choose any.
Running Unity 5.3.5f1, PlayMaker 1.8.1.f10 and last DataMaker in Ecosystem

Do you know why this may happen?

Thank you very much!

8
Hello!

I'm using the action Xml Select Single Node action, which is in the DataMaker package. I am using a xml file as source.

When I do the action with an xPath Query introduced by text it works fine, but the problems comes when I want to set the xPath Query by an string variable. It just don't allow me to select any string. I mean, they appear in the dropdown, but when I select one, the input remains in "None".

If I try to do it at runtime, it appears this error in the console:

"ArgumentException: Object type HutongGames.PlayMaker.FsmString cannot be converted to target type: System.Boolean
Parameter name: val
System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoField.cs:133)
System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/FieldInfo.cs:150)
HutongGames.PlayMakerEditor.ActionEditor.DoVariableSelection (System.Object userdata) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Editor/Classes/ActionEditor.cs:2779)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, Int32 selected) (at C:/buildslave/unity/build/artifacts/generated/common/editor/GenericMenuBindings.gen.cs:122)"

So I don't know if I am missing something or what, but I can't find why it happens. I've also tried to set it as "None" and then add more variables, but it just don't work...

Have somebody been in this problem?

Thank you!

9
Playmaker Help / Create Render Texture at runtime?[SOLVED]
« on: February 24, 2016, 02:41:37 AM »
Hello

Is it posible to create a Render Texture at runtime with Playmaker?

I tried with Create Object, but It doesn't work as it is not a GameObject.

I need to asign one RenderTexture to each prefab camera instantiated, so I would like to create them at runtime. It is posible to do it with Playmaker, or I have to do it in a script?

Thank you :)

10
Playmaker Help / UnityEngine.Camera Object variable type? [SOLVED]
« on: February 24, 2016, 02:30:38 AM »
Hello

I am instantiating a prefab around the game. This prefabs contains a camera. What I want to do is to asign a Render Texture to each instantiated cam. I have the GameObject in a variable, and what I would do is:

- Get Component. Save the camera component in an Object (UnityEngine.Camera) variable.
- Set Property > Tarjet Texture and asign it.

It is just what it is said in this post:
http://hutonggames.com/playmakerforum/index.php?topic=2791.msg12641#msg12641

My problem is that I can't find the UnityEngine.Camera Object type when I create a Object variable. Is it posible? Maybe I am doing something wrong?

Pages: [1]