Unity fungus got red line - unity3d

I got a problem Having the fungus plugin red line
But in unity editor it works normal.
It is a little problem but i want to fix it.
Can someone help?
I try to check visual studio install for VS 2019 has already got unity plugin.
And I try to use open c# project from unity editor
but it still got the problem
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Fungus;
public class TestVariablefungus : MonoBehaviour
{
public Flowchart flowchart;
public int missioncount = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void setFungusmission(int count)
{
//flowchart.SetBooleanVariable("missioncomplete", true);
missioncount= count;
flowchart.SetIntegerVariable("mission", missioncount);
}
public void setGrabMission(bool IsGrab)
{
flowchart.SetBooleanVariable("grabOnhand", IsGrab);
}
}

I found the problem myself.
That is because I put the project folder under a lot of level of folder.
Make the fungus package cannot catch the function.

Related

Unable to use TextMeshPro, only TextMesh available in Unity Code

I am trying to change the text of a textmesh pro in my unity project, so I added a TextMeshPro Text Component to my GameObject. Now, when I try to write TextMeshPro textmeshPro = GetComponent<TextMeshPro>();, I get the Error that TextMeshPro is not available in the Namespace. I used the import using TMPro;. The only thing available is TextMesh. Is this the Code equivalent to TextMeshPro?
Also, TMP_Text is not working for me. There are no suggestions form VS 2019 other than "TextMesh"
My Full Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class ContextMenuInteraction : MonoBehaviour
{
public string partName;
public GameObject assignedGameObject;
void Start()
{
TextMesh Test = assignedGameObject.GetComponent<TextMesh>();
TextMeshPro textmeshPro = GetComponent<TextMeshPro>();
}
// Update is called once per frame
void Update()
{
}
public void showNearContextMenu (GameObject target)
{
//use position of game object to spawn context menu near it
}
}
My TextMeshPro Object looks like this:
The problem is the component Type. You need find the component with this Type "TextMeshProUGUI" this is the text component for UI.
Example:
TextMeshProUGUI nameField;
nameField = GetComponent<TextMeshProUGUI>();
nameField.text = "some text";
enter image description here
For me correct
I think change compiler for example Vscode or VS or rider
Rebuild the project files. Edit > Preferences > External Tools > [Regenerate Project Files] - Problem solved by #hijinxbassist in the comments below the post

Unity Error: Debug does not contain definition for log. Coding In Visual Studio Code, also installed required packets but still not working

I am using VScode for Unity but, cannot run the program as it gives error:
"Debug does not contain definition for log"
Below code given
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.log("Welcome to Number Wizard");
Debug.log("Pick a Number and don't tell me what it is");
Debug.log("The highest number you can pick is 1000");
Debug.log("The lowest number u can pick is 1");
}
// Update is called once per frame
void Update()
{
}
}

How to use JNI in Unity

I have a JAR library that i need to use in a Unity project but i have never used JAR before,
i couldn't get JNI to work correctly
here is a simple code which outputs 0 but probably should return the correct hashcode of the java string??
public class test : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
AndroidJNIHelper.debug = true;
using (AndroidJavaObject jc = new
AndroidJavaObject("java.lang.String","test"))
{
int a = jc.CallStatic<int>("hashCode");
Debug.Log(a);
}
}
}
Problem was that i was using the editor after moving to android it worked perfectly .

Cannot call IVirtualButtonEventHandler Vuforia 5.0.10

Im using Unity 4.7.0 and Vuforia 5.0.10, i cannot call the IVirtualButtonEventHandler.
using UnityEngine;
using System.Collections;
public class VBEventHandler : MonoBehaviour, IVirtualButtonEventHandler
{
}
I just came across this, hope you're still using Unity & Vuforia. You need to add using Vuforia to make the call.
using UnityEngine;
using System.Collections;
using Vuforia;
Register the Virtual Button:
To add a virtual button to an image target, add the VirtualButton element and its attributes to the ImageTarget element in the .xml file.
XML Attributes:
Name - a unique name for the button
Rectangle - defined by the four corners of the rectangle in the
target's coordinate space
Enabled - a boolean indicating whether the button should be enabled
by default
Sensitivity - HIGH, MEDIUM, LOW sensitivity to occlusion
After Registering Virtual Button Code is simple then:
using UnityEngine;
using System.Collections;
using Vuforia;
public class Custom_VirtualButton : MonoBehaviour, IVirtualButtonEventHandler
{
// Use this for initialization
void Start () {
// here it finds any VirtualButton Attached to the ImageTarget and register it's event handler and in the
//OnButtonPressed and OnButtonReleased methods you can handle different buttons Click state
//via "vb.VirtualButtonName" variable and do some really awesome stuff with it.
VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();
foreach (VirtualButtonBehaviour item in vbs)
{
item.RegisterEventHandler(this);
}
}
// Update is called once per frame
void Update () {
}
#region VirtualButton
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb)
{
Debug.Log("Helllllloooooooooo");
}
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)
{
Debug.Log("Goooooodbyeeee");
}
#endregion //VirtualButton
}

Accessing functions from different scripts in unity C#

I am relatively new to unity and I'm trying to make collectibles in a game but i need to keep a tally of how many items have been collected but still have the collected item disappear. So far I have this. And yes the collectables are hairspray :p
Collection.cs
using UnityEngine;
using System.Collections;
public class Collection : MonoBehaviour {
public control controlSrc;
void OnTriggerEnter () {
controlSrc.AddScore();
killHairSpray();
}
void killHairSpray () {
Destroy(gameObject);
}
}
control.cs
using UnityEngine;
using System.Collections;
public class control : MonoBehaviour {
public int hcTot = 0;
public void AddScore () {
hcTot = hcTot + 1;
Debug.Log("Working");
}
}
I'm not sure why it isn't working but the console says;
NullReferenceException: Object reference not set to an instance of an object
Collection.OnTriggerEnter () (at Assets/Collection.cs:10)
Thanks:) this has been driving me crazy!
You most likely haven't connected anything to the controlSrc variable so it's empty. Hence the null reference exception.
In the Unity editor select the GameObject with the Collection.cs script, then in the Inspector set the controlSrc (most likely listed as "Control Src") by assigning the game object containing the control.cs script.