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 - looi

Pages: [1] 2
1
Action Requests / Re: get File Name From Path
« on: June 06, 2019, 10:46:06 AM »
It works great. Thank you Jean! :)

2
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;
}
}
}

3
Action Requests / Re: ArrayList Get Vertex Positions (world space)
« on: April 12, 2019, 02:43:11 PM »
OK, worldSpace bool added:

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 ArrayListGetVertexPositions2 : 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 bool worldSpace;


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


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;
}

            if (worldSpace)
            {
                for (int i = 0; i < _mesh.mesh.vertices.Length; i++)
                {
                    proxy.arrayList.Add(_mesh.transform.TransformPoint(_mesh.mesh.vertices[i]));
                }
            }
            else
            {
                proxy.arrayList.InsertRange(0, _mesh.mesh.vertices);
            }


}
}
}

4
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);


}
}
}

5
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

6
PlayMaker Help / Re: Create Render Texture at runtime?
« on: February 13, 2019, 11:46:47 AM »
Thank you Jean!  :D

7
PlayMaker Help / Re: [SOLVED] Large FSM severely slow
« on: October 10, 2018, 07:16:40 PM »
I was suffering this problem and until now I've found the solution that gave me back the fluidity: in Preferences I've disabled the option "Enable Real Time Error Checker".

I've got like more than 200 playmaker "errors" and It seems the editor was looking on them every frame or something.

So anyone having this issue shoud try this. It definitely saved my productivity! :)

8
Share New Actions / Re: Get the remainder of two float values
« on: July 26, 2018, 07:25:42 PM »
Oooh! Thank you so much! This has helped me a lot! I looked for it in the Ecosystem and I couldn't find it.
Love youuu!  <3

9
PlayMaker Help / Re: Access PlayMakerHashTableProxy from scipt
« on: May 18, 2018, 10:04:32 AM »
Finally I found a workarround: to parse the DictionaryEntry.Value. I know this is nonsense, but It works for me and I do not reach something better.
This is the entire function:

Code: [Select]
public void closestColor3(Color32 target){
float hue1 = getHue (target.r, target.g, target.b);
var num1 = ColorNum(target);
float minimaDiferenciaColores = 10000;
string key="";
int flag = 0;
int index = 0;
Color valor; Color32 valor32; Color colorParecido = new Color();
foreach (DictionaryEntry colorDeLaLista in listaNcs.hashTable) {
flag++;
float Rvalor = float.Parse (colorDeLaLista.Value.ToString ().Substring (5, 5));
float Gvalor = float.Parse (colorDeLaLista.Value.ToString ().Substring (12, 5));
float Bvalor = float.Parse (colorDeLaLista.Value.ToString ().Substring (19, 5));
valor = new Color (Rvalor,Gvalor,Bvalor);
valor32 = (Color32)valor;
float diferenciaColores = Math.Abs(ColorNum(valor) - num1) + getHueDistance(getHue(valor32.r, valor32.g, valor32.b), hue1);
if (diferenciaColores < minimaDiferenciaColores) {
minimaDiferenciaColores = diferenciaColores;
key = colorDeLaLista.Key.ToString ();
index = flag;
colorParecido = valor;
}
}
img_NCS.color = colorParecido;
txt_NCS.text = key;
}

If you have any suggestion to improve it, please tell me. Thanks! :)

10
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!

11
PlayMaker Bug Reporting / Re: I cannot add new Global Variable
« on: December 27, 2017, 11:06:26 AM »
Unity 2017.2.0f3
Playmaker 1.8.6.
For the moment I've just avoid the bug by adding the new global variable using the "NEW GLOBAL VARIABLE" option in an action.

Using ArrayMaker, Ecosistem and Easy Save 2

12
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)

13
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!

14
PlayMaker Help / Re: Xml Select Nodes by Fsm String
« on: June 20, 2016, 12:36:30 AM »
Thank you Jean!

I will try to use another option then

15
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!

Pages: [1] 2