- Home /
Using private class strings with iTween event calls
Hello, I am wondering if it is possible to call an iTween event on a string of gameobjects? I'm getting an error currently, see picture below.
I would like to call iTween events on any number of gameobjects, when it finds the object that has the script on it, it runs that script.
So this is the kind of inspector look i am striving for:
and here is the code snippets that I added:
var Levels:LevelCount[];
private class LevelCount {
var Level : GameObject;
}
//This is found in the function update in an if statement, SEE FULL CODE for placement.
iTweenEvent.GetEvent(Levels, "L1MoveLToGridSpace3").Play();
Full Code:
var ButtonLeft: boolean;
var ButtonRight: boolean;
var GridCount = 0;
var Levels:LevelCount[];
private class LevelCount {
var Level : GameObject;
}
function Update () {
// verify if one of the arrows was clicked:
DetectButtonClick();
// now you have ButtonLeft or ButtonRight true if the corresponding
// arrows were clicked - place your code here
GridSystem ();
}
function DetectButtonClick(){
ButtonLeft = false; // assume no clicks initially
ButtonRight = false;
if (Input.GetMouseButtonDown(0)){ // if left button pressed...
// create a ray passing through the mouse pointer:
var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
if (Physics.Raycast(ray, hit)){ // do a raycast
if (hit.transform.name == "ArrowLeft"){ // left arrow clicked?
ButtonLeft = true;
//Debug.Log ("you pressed the left arrow");
}
else
if (hit.transform.name == "ArrowRight"){ // right arrow clicked?
ButtonRight = true;
//Debug.Log ("you pressed the right arrow");
}
}
}
}
function GridSystem () {
if (ButtonRight) {
GridCount++;
//print("Right Arrow clicked");
}
if (ButtonLeft) {
GridCount--;
//print("Left Arrow clicked");
}
GridCount = Mathf.Clamp (GridCount, 0, 2);
if (GridCount == 0) {
if (ButtonRight) {
//Move all level objs left one grid
Debug.Log (GridCount);
}
if (ButtonLeft) {
//Move all level objs right one grid
iTweenEvent.GetEvent(Levels, "L1MoveLToGridSpace3").Play();
//Debug.Log (GridCount);
}
}
if (GridCount == 1) {
if (ButtonRight) {
//Move all level objs left one grid
Debug.Log (GridCount);
}
if (ButtonLeft) {
//Move all level objs right one grid
Debug.Log (GridCount);
}
}
if (GridCount == 2) {
if (ButtonRight) {
//Move all level objs left one grid
Debug.Log (GridCount);
}
if (ButtonLeft) {
//Move all level objs right one grid
Debug.Log (GridCount);
}
}
}
and my error i receive, when i try to use the Levels string to access the gameobjects i attached to this script in the inspector, in order to find an event name thats specific to just one of those "Levels".
Thanks for the help, Daniel
Just for the heads up i am using the iTween Visual Inspector Editor (it creates a script at runtime thats when the animation is called).
I believe what i am trying to do may be impossible, If any one still has an idea let me know! Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220613105707im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
iTween Visual Editor Event Call from C# to Javascript 1 Answer
What is wrong with this script? 2 Answers
How to Implement System.StringBuilder into JavaScript? 2 Answers
2.5D ledge hang with javascript 0 Answers