Перевод кода в css - Форум - Все для Unity3d

Все для Unity3d> Перевод кода в css - Форум>
Страница 1 из 11
Форум » Unity » Вопросы » Перевод кода в css
Перевод кода в css
ZayRoxДата: Понедельник, 04.08.2014, 13:21 | Сообщение # 1
Новый писатель
Группа: Пользователи
Сообщений: 1
Статус: Offline
Вот код js как перевсти в css
Код
var inventoryIcon:Texture2D;//this is what will be displayed in the demos On Screen GUI.
var isStackable=false;//If this is true it will be stacked in the inv. if not then it wont!
//Stacking will be added in the next update.
var maxStack=9;//each stack can be this big.

function OnMouseDown(){//When you click an item
    if(!collider.isTrigger){//im going to check if its collider is active. since i know i deactivate it when
//it gets picked up. BUT you could also make a var "canGet" or somthing and change it when its picked up and dropped.
//basically we dont want to pick up somthing, we already have.
       var playersinv=FindObjectOfType(Inventory);//finding the players inv. I suggest when making
       playersinv.AddItem(this.transform);
       MoveMeToThePlayer(playersinv.transform);//moves the object, to the player
    }
}

function MoveMeToThePlayer(theplayer:Transform){//This will basically make the item stay where the player is
//as long as its in the players inventory. This can also be done multiple ways, but ill stick with an easy one.
    transform.collider.isTrigger=true;//makes it undence.
    transform.renderer.enabled=false;//makes it invisible
    transform.parent=theplayer;//makes the object parented to the player.
    transform.localPosition=Vector3.zero;//now that the item is parented to the player
    //i can set the localPosition to 0,0,0 and it will be ontop of the player. and move around with him/her
}

function BeDropped(){//This will drop the item wherever the player is.
    //since the player has the item parented to him, and at his position (locally) we are going to just  
    //drop the item where it already is
    transform.collider.isTrigger=false;//reactive its collider.
    transform.renderer.enabled=true;//allow it to be seen again.
    transform.parent=null;//give it no parent.
}

/*
Alternate ways to make objects stay with a player. is just move it to an
unused part of the map and deactivate it like i did. Its invisible so it will be unseen
and its untouchable :P.
If you are switching scenes. for world areas or somthing. you can keep inventory objects
alive by doing "DontDestroyOnLoad(this)". These are just some tips. Design however youd
like to :P.
*/


И вот етот

Код
var Contents:Transform[];

function AddItem(Item:Transform){//Add an item to the inventory.
    var newContents=new Array(Contents);
    newContents.Add(Item);
    Debug.Log(Item.name+" Has been added to inventroy");
    Contents=newContents.ToBuiltin(Transform);
}
function RemoveItem(Item:Transform){//Removed an item from the inventory.
    print("made it here");
    var newContents=new Array(Contents);
    var index=0;
    var shouldend=false;
    for(var i:Transform in newContents){
       if(i==Item){
          Debug.Log(Item.name+" Has been removed from inventroy");
          newContents.RemoveAt(index);
          shouldend=true;
          //No need to continue running through the loop since we found our item.
       }
       index++;//keep track of what index the item is and remove it.
       if(shouldend){
          Contents=newContents.ToBuiltin(Transform);
          return;
       }
    }
}


Всём добра :)
 
berilДата: Понедельник, 04.08.2014, 23:32 | Сообщение # 2
Новый писатель
Группа: Пользователи
Сообщений: 31
Статус: Offline
Никак wacko
CSS — формальный язык описания внешнего вида документа
 
ZayRoxДата: Понедельник, 04.08.2014, 23:51 | Сообщение # 3
Новый писатель
Группа: Пользователи
Сообщений: 1
Статус: Offline
Цитата beril ()
Никак CSS — формальный язык описания внешнего вида документа
Спасибо за ответ! +сик в подарок


Всём добра :)
 
Форум » Unity » Вопросы » Перевод кода в css
Страница 1 из 11
Поиск:
Свернуть
Развернуть
Необходима авторизация
0
ТОП-5 САЙТА
НОВЫЕ ИГРЫ
ГОРЯЧИЕ ТЕМЫ
СЛУЧАЙНЫЕ ФАЙЛЫ