0
Answered

Game Creator Hub - "Reflection Components Variables Methods" - FAIL ?

markusrgb 5 months ago in Other updated by Marti (Lead Developer) 4 months ago 5

Hello, everyone,

I have problems with several scripts from the Game Creator Hub.

Mainly it concerns the package "Reflection Components Variables Methods

With all scripts where I have to access a component as an option I always get an error:

For comparison, with other scripts that work similarly I have no problems

In these scripts I access components or variables.

The first two work without problems:

(ConditionHasLocalVariable) and (ConditionIsComponentInGameObject)

But as soon as I use the script "ConditionComponentVariableExists" I get an error:



In the meantime I found out that the "Component Name" must be written without spaces.

It doesn't matter if I try to assign the value directly at "Value" or as a "string" via a "Global Variable" or a "LocalVariable".



As soon as the value "Component Name" is called I get an error

The bug affects all scripts from this package:
I have the same problem in each one.




Am I doing something wrong here?


Thank you.

Markus


Unity version:
2019.3.11f1
Game Creator version:
1.1.7
BAD, I'M UNSATISFIED

unfortunately he's not answering, could you take a look at the script I posted above, Marti?

thanks already.

Satisfaction mark by markusrgb 4 months ago
Answered

I'd recommend contacting the publisher of these Actions. However, I haven't seen Duffer lately on Discord.

Hi, Marti,

I have already written Niall Edwards in the GameCreatorHub. But I'm afraid he won't get back to me.

Unfortunately I need a lot of his scripts, and I expected them to work when I use them.

Unfortunately there are no other alternatives.

If they don't work, the GameCreator will lose a lot of useful tools.

I have already tried to change one of his scripts with my hardly existing programming knowledge.

Unfortunately I always get the same error message no matter what I try:

Could you perhaps show me what I have to change to make the script work with this example:

(The remaining 50 scripts are all similarly structured ... I could possibly adapt them myself using the changed script).

here the original script:


namespace GameCreator.Core
{
using UnityEngine;
using GameCreator.Variables;
using System.Reflection;

[AddComponentMenu("")]
public class ActionSetComponentVariableValueAsBool : IAction
{
public enum PublicPrivateBoth
{
AllVariables,
OnlyPublicVariables,
OnlyPrivateVariables,
}

public GameObjectProperty gameobjectToCheck = new GameObjectProperty();

[Space(5)]
public StringProperty componentName = new StringProperty();

[Space(5)]
public StringProperty variableName = new StringProperty();

[Space(5)]
[Header("Search for All, just Public or just Private named Variables?")]
public PublicPrivateBoth searchCriteria = PublicPrivateBoth.AllVariables;

[Space(15)]
[Header("Ensure identified Variable to set to is of Bool type only!")]
public BoolProperty boolToSetTo = new BoolProperty();

private GameObject go;
private string compName;
private string fieldName;
private bool boolValue;

public override bool InstantExecute (GameObject target, IAction[] actions, int index)
{
go = gameobjectToCheck.GetValue(target);
compName = componentName.GetValue(target);
fieldName = variableName.GetValue(target);
boolValue = boolToSetTo.GetValue(target);

if (go.GetComponent(compName))
{
if (searchCriteria == PublicPrivateBoth.AllVariables)
{
go.GetComponent(compName).GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).SetValue(obj: go.GetComponent(compName),boolValue);
}

if (searchCriteria == PublicPrivateBoth.OnlyPublicVariables)
{
go.GetComponent(compName).GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public).SetValue(obj: go.GetComponent(compName), boolValue);
}

if (searchCriteria == PublicPrivateBoth.OnlyPrivateVariables)
{
go.GetComponent(compName).GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance).SetValue(obj: go.GetComponent(compName), boolValue);
}
}

return true;
}


#if UNITY_EDITOR
public static new string NAME = "Custom/ComponentsAndVariables/ActionSetComponentVariableValueAsBool";
#endif
}
}


If not then I won't be able to continue with my project.



(The function to search "for all, only public or only private" variables is not needed.)





thanks a lot

Markus

Sorry but since we did not create these Actions, I would have to study the entire set made by Niall and currently I don't have the time to do so.

Ok, just found this post. So that neams NO.

So my last post would mean GC will not have reflection anymore?

SAD

As it obviously did have this possibility before!


And now there are a lot of scripts that I will not be able to use unless I also use playmaker at the same time as GC to do that. Pitty as I would rather just use GC.

So I will sit back and rethink what am I going to do.

It's not that Game Creator had this but doesn't support it anymore. Game Creator Hub is a place when any developer can share their creations, for free, so other community members can benefit.

Niall is a user, just like any other, who decided to invest his time and published these Actions. However, for reasons he is not obliged to disclose, he is not updating this Actions any more. I created that platform free to use so other users could symbiotically help each other. Not to force developers maintain for free and forever their additions.