나는 C 번호에 unityscript에서 코드의 간단한 조각을 변환 (이해)하기 위해 노력하고있어 : 전체 코드는 여기에서 찾을 수 있습니다유니티 C# 배열 타입 에러 (unityscript에서 변환 할 때)
private var actionList = new Array();
function Start()
{
actionList = new Array(12);
for(i=0; i<actionList.length; i++)
actionList[i] = new Array(4);
for(i=0; i<actionList.length; i++)
{
actionList[i][1] = Rect(50+(i*55),50, 50, 50);
actionList[i][2] = new Array("action");
}
actionList[0][3] = KeyCode.Alpha1;
actionList[1][3] = KeyCode.Alpha2;
actionList[2][3] = KeyCode.Alpha3;
actionList[3][3] = KeyCode.Alpha4;
actionList[4][3] = KeyCode.Alpha5;
actionList[5][3] = KeyCode.Alpha6;
actionList[6][3] = KeyCode.Alpha7;
actionList[7][3] = KeyCode.Alpha8;
actionList[8][3] = KeyCode.Alpha9;
actionList[9][3] = KeyCode.Alpha0;
actionList[10][3] = KeyCode.Minus;
actionList[11][3] = KeyCode.Equals;
}
function OnGUI()
{
for(i=0; i<actionList.length; i++)
{
if(actionList[i][1] != null)
drawButton(actionList[i][1]);
}
}
function drawButton(rect)
{
GUI.Button(rect, "Hello");
}
: Creating a Drag and Drop Spell Bar
C#에서이에서 내 촬영합니다 (keymappings 밖으로 떠나) :
using UnityEngine;
using System.Collections.Generic;
public class SpellBar : MonoBehaviour
{
private object[][] actionList;
void Start()
{
actionList = new object[12][];
for (int i=0; i<actionList.Length; i++)
actionList[i] = new object[4];
for (int i=0; i<actionList.Length; i++)
{
actionList[i][1] = new Rect(50+(i*55), 50, 50, 50);
}
//Keymappings
}
void OnGUI()
{
for(int i=0; i<actionList.Length; i++)
{
if(actionList[i][1] != null)
DrawButton(actionList[i][1]);
}
}
void DrawButton(Rect rect)
{
GUI.Button(rect,"Hello");
}
}
내가 이곳에 오기 오류 OnGui에, DrawButton을 사용 (ACTIONLIST,). 오류 : '개체 식'을 "UnityEngine, Rect"유형으로 변환 할 수 없습니다.
유니티 스크립트 나 C#에서 숙련 된 프로그래머가 아닙니다. 수 시간 동안 Google을 검색하여 Lists, ArrayLists 등을 시도했지만 솔루션을 찾을 수 없습니다. . 사전에 Thnx를 입력하십시오.
EDIT 27-11-2012
그래서 새로운 관련 문제가 발생했습니다.이 항목을 여기에서 편집해야할지 모르겠지만 답장에서 제대로 형식을 지정할 수 없습니다.
변환하려고하는 JavaScript 코드에서 다음 코드는 배열에 클래스를 저장하는 데 사용됩니다.
이것이 정확히 원하는 방식은 아니지만 배열에 메서드를 저장할 수 있기를 원하지만 C#으로이 메서드를 찾을 수는 없습니다. 그것은 단순히 불가능한가요?
(예) 나는 이런 식으로 뭔가를 할 노력하고있어 : 자바 스크립트와는 달리
//In addition to what I posted above
void Start()
{
actionList[i][0] = void FireBall();
}
void FireBall()
{
Texture2D icon = Resources.Load("icon_fireball") as Texture2D;
String description = new String("Shoot a ball of fire");
//etc
}
그건 자바가 아니에요. Javascript 일 수도 있지만 자바가 아닙니다. –
사람들이 "Java"와 "Javascript"를 혼동하는 것을 듣고 나는 움츠 리다. 피상적 유사점이 있지만 가장 중요한 측면에서 "Java"와 "Javascript"는 별개입니다. 게시물을 편집하고 제목을 "Javascript"로 변경했습니다. – paulsm4
Thnx, 자바 스크립트를 자바 스크립트로 편집했습니다. 여기 N00b – downdf