проблема= при запуске mouseUp, mouseDown , even.type.mouseUp -сробатывают или через раз, или (токое чувство) что больше .чем раз за вызов функции OnGUI. тоже самое через input
пример-
Синтаксис:
Используется javascript
function OnGUI () {
//cursor
var ob : GameObject ;
var e : Event = Event.current;
if ((e.mousePosition.x/Screen.width*10)<10)
{ cursor.x=parseInt (e.mousePosition.x/Screen.width*10);}
if ((10-e.mousePosition.y/Screen.height*10)<10 && (10-e.mousePosition.y/Screen.height*10)>0)
{ cursor.y=parseInt (10-e.mousePosition.y/Screen.height*10);}
// mouse click
if(Input.GetMouseButtonUp(0))
{
var xy=(cursor.y*10+cursor.x);
// somthing found
if (fildarray[xy].x==1) {
var inx=fildarray[xy].y;
ob=GameObject.Find(objarr[inx]);
var otherScript: preff = ob.GetComponent(preff);
if (otherScript.st==0) {
isselect=ob;
otherScript.st=1;}
else if (otherScript.st==1) {
isselect=null;
otherScript.st=0;}
}
//cursor
var ob : GameObject ;
var e : Event = Event.current;
if ((e.mousePosition.x/Screen.width*10)<10)
{ cursor.x=parseInt (e.mousePosition.x/Screen.width*10);}
if ((10-e.mousePosition.y/Screen.height*10)<10 && (10-e.mousePosition.y/Screen.height*10)>0)
{ cursor.y=parseInt (10-e.mousePosition.y/Screen.height*10);}
// mouse click
if(Input.GetMouseButtonUp(0))
{
var xy=(cursor.y*10+cursor.x);
// somthing found
if (fildarray[xy].x==1) {
var inx=fildarray[xy].y;
ob=GameObject.Find(objarr[inx]);
var otherScript: preff = ob.GetComponent(preff);
if (otherScript.st==0) {
isselect=ob;
otherScript.st=1;}
else if (otherScript.st==1) {
isselect=null;
otherScript.st=0;}
}
input менял на even.type -делал через update - результат тот же
код который по моему мнению -должен рабоать как переключатель -переменой otherscript.st , по поисполнению возвращает 0
И ворос в догонку . Использование функции GameObject.Find связанно с тем, что я не смог в массив сам обьект (инстенс) запушить:
var clone= Instantiate(shp, Vector3 (x, 0, y), Quaternion.identity);
objarr.Push (clone);
вот так не работает- не распознаетса класс при долнейшим вызове (( ( кто знае почиму -подскажите плииз) пришлость делать :
var clone= Instantiate(shp, Vector3 (x, 0, y), Quaternion.identity);
clone.name=(objarr.length).ToString();
objarr.Push (clone.name);
и искать через find ,что если верить скрипт референсу являетса очень ресурсоёмко.
Сам я не програмистб немного мел и макс скрипт -потому прошу не сильно матюкать я больше по анимации и ригу ( юнити -первые експеременты в Програмировании)
моё портфале-
https://www.youtube.com/watch?v=C4pLxzJ3xHY&feature=g-upl
PS. со школы плохо с языком, ни коем случаем не хотел обидить людей будующих читать пост.