Hello!
I cant "press" button on scene into script. I've scene with atoms:
1. Trigger UIButton - name "Button1". When I press button - doing some actions (included in tab "Button trigger");
2. Shape Cube - "Cube1", with my plugin-script;
How "to press" button programmatically into my plugin-script?
Text script:
I cant "press" button on scene into script. I've scene with atoms:
1. Trigger UIButton - name "Button1". When I press button - doing some actions (included in tab "Button trigger");
2. Shape Cube - "Cube1", with my plugin-script;
How "to press" button programmatically into my plugin-script?
var FindedButton = GameObject.Find("Button"); // Button (UnityEngine.GameObject)
FindedButton.onClick.Invoke(); // error: Type `UnityEngine.GameObject' does not contain a definition or method `onClick'.
Also don't work variants:
FindedButton.Click();
FindedButton.onClick();
FindedButton.Trigger();
var myTrigger = FindedGameObject.GetComponent<Trigger>(); // Also GetComponentInChildren
myTrigger.onClick.Invoke();
myTrigger.Click();
myTrigger.onClick();
myTrigger.Trigger();
var myButton= FindedGameObject.GetComponen<Button>(); // Also <UIButton>, also GetComponentInChildren
myButton.onClick.Invoke();
myButton.Click();
myButton.onClick();
myButton.Trigger();
Also tried with parents-objects:
FindedButton.transform.parent.gameObject // Canvas (UnityEngine.GameObject)
FindedButton.transform.parent.parent.gameObject // rescaleObject (UnityEngine.GameObject)
FindedButton.transform.parent.parent.gameObject // object (UnityEngine.GameObject)
FindedButton.transform.parent.parent.parent.gameObject // reParentObject (UnityEngine.GameObject)
FindedButton.transform.parent.parent.parent.parent.gameObject // Button1 (UnityEngine.GameObject)
There is only a scene above - SceneAtoms (UnityEngine.GameObject)
FindedButton.onClick.Invoke(); // error: Type `UnityEngine.GameObject' does not contain a definition or method `onClick'.
Also don't work variants:
FindedButton.Click();
FindedButton.onClick();
FindedButton.Trigger();
var myTrigger = FindedGameObject.GetComponent<Trigger>(); // Also GetComponentInChildren
myTrigger.onClick.Invoke();
myTrigger.Click();
myTrigger.onClick();
myTrigger.Trigger();
var myButton= FindedGameObject.GetComponen<Button>(); // Also <UIButton>, also GetComponentInChildren
myButton.onClick.Invoke();
myButton.Click();
myButton.onClick();
myButton.Trigger();
Also tried with parents-objects:
FindedButton.transform.parent.gameObject // Canvas (UnityEngine.GameObject)
FindedButton.transform.parent.parent.gameObject // rescaleObject (UnityEngine.GameObject)
FindedButton.transform.parent.parent.gameObject // object (UnityEngine.GameObject)
FindedButton.transform.parent.parent.parent.gameObject // reParentObject (UnityEngine.GameObject)
FindedButton.transform.parent.parent.parent.parent.gameObject // Button1 (UnityEngine.GameObject)
There is only a scene above - SceneAtoms (UnityEngine.GameObject)
Text script:
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleJSON;
using UnityEngine.UI;
using UnityEngine.XR;
using UnityEngine.Events;
public class MyPluginTest : MVRScript {
protected UIDynamicButton myButton;
public override void Init() {
myButton = CreateButton("ButtonInPlugin", false);
myButton.height = 100;
myButton.button.onClick.AddListener(delegate() {FindGameObject();} );
}
void FindGameObject() {
var FindedGameObject = GameObject.Find("Button"); // Button (UnityEngine.GameObject)
//FindedGameObject.onClick.Invoke();
//var buttonRed = FindedGameObject.GetComponentInChildren<Text>();
//buttonRed.text = "POP";
//var t = GameObject.Find("LabelInput");
}
void Update() {}
}