Game Development Reference
In-Depth Information
2. Next, we go to the Init() function and add the following highlighted code to
set up all variables:
// Unity JavaScript user:
function Init ( skillBoxTexture : Texture ) : void {
_guiContent = new GUIContent("");
_skillBoxTexture = skillBoxTexture;
_selectedSkill = 0;
_scrollPosition = Vector2.zero;
_textureCount = textures.Length;
}
// C# user:
public void Init ( Texture skillBoxTexture ) {
_guiContent = new GUIContent("");
_skillBoxTexture = skillBoxTexture;
_selectedSkill = 0;
_scrollPosition = Vector2.zero;
_textureCount = textures.Length;
}
3. Then, we will set up the scroll view for our skill textures, which is very similar to
the one we set in the ItemsContainer class, but in this function, we will have
a horizontal scroll view instead. So, add the new function after the Init() func-
tion and name it SetupSkillScrollBar() ; add the highlighted code as fol-
lows:
// Unity JavaScript:
function Init ( skillBoxTexture : Texture ) : void {
}
function SetupSkillScrollBar () : void {
var itemCount = _textureCount+1;
var itemsContent : GUIContent[] = new
GUIContent[itemCount];
Search WWH ::




Custom Search