- Home /
Problem is not reproducible or outdated
Got a problem with script 4 dialogues
Hi hi all, so i've got a problem with a script, i think that's 'cos in Unity 4 javascript shouldn't have some Boo elements. But in fact i don't know, how i can liquidate a problem. So, that's a script:
public var dialogueSkin : GUISkin;
public var startOn : int = 0;
public var defaultImg : Texture2D;
public var defaultAudio : AudioClip;
public var dialogue : DialogueEntry[] = [new DialogueEntry()];
public var display : DialogueEntry = new DialogueEntry();
public var waitTime : float = 0.2;
public var lineCount : int = 0;
public var timeStart : float = 0.0;
public var textSpeed : float = 80.0;
public var parsedText : String[];
public var pwEntry : String = "";
public var toLoad : int = -1;
public var curItem : int = 0;
public var history : Array = new Array();
public var phase : int = 0;
public var curContent : GUIContent = GUIContent("");
public var glow : float = 0;
public var aud : AudioSource;
public var bools : boolean[] = [false,false,false,false];
public var ints : int[] = [0,0,0,0];
public var strings : String[] = ["","","",""];
public var jumpto : int;
public var s : Vector2 = Vector2.zero;
class DialogueEntry {
public var longText : String;
public var img : Texture2D;
public var choices : DialogueChoice[];
public var choiceMode : int = 1;
public var links : Link[];
public var next : int;
public var editor : boolean;
public var pos : int = 0;
// 0 - top, 1 - bottom, 2 - middle
public var passwords : DialogueChoice[];
public var incorrect : int;
public var exit : DialogueChoice;
public var align : int;
public var mode : int;
public var narration : AudioClip[];
public var script : String;
// 0 - next, 1 - choice, 2 - password, 3 - event, 4 - end
function DialogueEntry () {
longText = "New entry";
next = 0;
editor = false;
incorrect = 0;
align = 0;
exit = new DialogueChoice("Exit");
mode = 0;
}
}
class DialogueChoice {
public var shortText : String;
public var next : int;
public var editor : boolean;
function DialogueChoice () {
shortText = "New Choice";
editor = false;
}
function DialogueChoice (s:String) {
shortText = s;
editor = false;
}
}
class Link {
public var shortText : String;
public var url : String;
function Link () {
shortText = "URL Description";
url = "http://";
}
}
function Start () {
Restart ();
}
function OnEnable () {
Restart();
}
function OnDisable () {
if (aud) {
if (aud.clip) {
if (aud.isPlaying) aud.Stop();
}
}
}
function Update () {
var text = parsedText[lineCount];
var chars = (Time.time-timeStart)*textSpeed;
if (chars0) {
if (display) {
GUI.skin = dialogueSkin;
if (curContent) {
switch (display.pos) {
case 0:
GUILayout.BeginHorizontal("textbox",GUILayout.Width(Screen.width));
if (display.align==0&&curContent.image) GUILayout.Label(curContent.image,"img");
GUILayout.Label(curContent.text,"text");
if (display.align==1&&curContent.image) GUILayout.Label(curContent.image,GUILayout.Width(256));
GUILayout.EndHorizontal();
break;
case 1:
GUI.Box(Rect(0,Screen.height-120,Screen.width,120),curContent,"textboxplayer");
break;
case 2:
GUI.Box(Rect(30,Screen.height/2-60,Screen.width-60,120),curContent,"textboxmiddle");
break;
}
/* for (var l in display.links) {
GUILayout.Button(l.shortText);
}*/
DoNextButton();
}
if (display.choices) {
if (display.choices.length>0&&lineCount>=parsedText.length-1&&display.mode==1) {
if (display.choiceMode==1) {
ShowWheel();
} else {
ShowList();
}
}
}
}
}
}
}
function DoNextButton () {
switch(display.mode) {
case 0:
if (lineCount0) {
if (GUI.Button(Rect(0,Screen.height-163,Screen.width/2,43),display.choices[0].shortText,"r1c1active")) toLoad=display.choices[0].next;
} else {
GUI.Label(Rect(0,Screen.height-163,Screen.width/2,43),"");
}
if (display.choices.length>1) {
if (GUI.Button(Rect(Screen.width/2,Screen.height-163,Screen.width/2,43),display.choices[1].shortText,"r1c2active")) toLoad=display.choices[1].next;
} else {
GUI.Label(Rect(Screen.width/2,Screen.height-163,Screen.width/2,43),"");
}
if (display.choices.length>2) {
if (GUI.Button(Rect(0,Screen.height-120,Screen.width/2,40),display.choices[2].shortText,"r2c1active")) toLoad=display.choices[2].next;
} else {
GUI.Label(Rect(0,Screen.height-120,Screen.width/2,40),"");
}
if (display.choices.length>3) {
if (GUI.Button(Rect(Screen.width/2,Screen.height-120,Screen.width/2,40),display.choices[3].shortText,"r2c2active")) toLoad=display.choices[3].next;
} else {
GUI.Label(Rect(Screen.width/2,Screen.height-120,Screen.width/2,40),"");
}
if (display.choices.length>4) {
if (GUI.Button(Rect(0,Screen.height-80,Screen.width/2,51),display.choices[4].shortText,"r3c1active")) toLoad=display.choices[4].next;
} else {
GUI.Label(Rect(0,Screen.height-80,Screen.width/2,51),"");
}
if (display.choices.length>5) {
if (GUI.Button(Rect(Screen.width/2,Screen.height-80,Screen.width/2,51),display.choices[5].shortText,"r3c2active")) toLoad=display.choices[5].next;
} else {
GUI.Label(Rect(Screen.width/2,Screen.height-80,Screen.width/2,59),"");
}
}
function ShowList () {
GUILayout.BeginArea(Rect(0,Screen.height-150,Screen.width,150),"","box");
s = GUILayout.BeginScrollView(s);
for (var c in display.choices) {
if (GUILayout.Button(c.shortText,GUILayout.Height(30))) toLoad = c.next;
}
GUILayout.EndScrollView();
GUILayout.EndArea();
}
function ProgressLineCount () {
timeStart = Time.time;
lineCount++;
PlayClip (curItem);
}
function FixedUpdate () {
if (toLoad!=-1) {
LoadDialogue(toLoad);
s = Vector2.zero;
}
toLoad = -1;
}
function StartGlow () {
GUI.color.a = glow;
}
function EndGlow () {
GUI.color.a = 1.0;
}
function PlayClip (i:int) {
if (aud.clip) {
if (aud.isPlaying) aud.Stop();
}
if (dialogue[i].narration) {
if (dialogue[i].narration.length>lineCount) {
if (dialogue[i].narration[lineCount]) {
aud.clip = dialogue[i].narration[lineCount];
aud.loop = false;
aud.Play();
}
}
}
}
Console write me: "`UnityScript.Scripting.IEvaluationDomainProvider' interface member implementation must be public or explicit." Help me, please. P.S. sorry for my english
for any help, please format your code. You can do this by highlighting all your code, then clicking the 10101 button at the top of the edit window.
Though, it may be easier just to delete the code, paste it in again from the source, then highlight all the code and press the 101010 button at the top of the edit window before posting. When you don't mark your code as code, the text gets html escaped and it gets really hard to reformat it.
EDIT : I have formatted this one for you. Please check the code is the same as what you have.
Sure. Full message:
Assets/Resources/Scripts/DialogueInstance.js(1,1): BCE0172: `UnityScript.Scripting.IEvaluationDomainProvider' interface member implementation must be public or explicit.
it appears that the error is from the very start do you have #pragma strict? if so try deleting it