InspectorScript.cs
4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//Log Dir http://docs.unity3d.com/Manual/LogFiles.html
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
using System.IO;
using System.Runtime.InteropServices;
public class InspectorScript : MonoBehaviour {
[DllImport ("CorePlugin")] public static extern int coreInitialize();
[DllImport ("CorePlugin")] private static extern IntPtr coreExecute();
[DllImport ("CorePlugin")] public static extern int coreFinalize();
public static float hSliderValue = 1.1f;
public Boolean isCaptionsActive = true;
string alfabeto = "0123456789,ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string stringPre; string[] stringPos;
AnimationClip aniClip;
public String glosa;
GameObject ICARO;
Animation COMPONENT_ANIMATION;
void Start( ){
try{ Debug.Log("Inicializando: "+coreInitialize( )); }catch(Exception e){ Debug.Log (e.ToString());}
ICARO = GameObject.FindGameObjectWithTag("avatar");
COMPONENT_ANIMATION = ICARO.GetComponent<Animation>();
addAlpha( );
}
public void setSlider( float x ){
hSliderValue = x;
}
void addAlpha( ){
foreach( char letter in alfabeto ){
aniClip = Resources.Load<AnimationClip> ("ANIMS/alpha/"+letter);
if( aniClip )
COMPONENT_ANIMATION.AddClip(aniClip, ""+letter);
else
Debug.Log("Anim "+letter+" not found");
}
}//addAlpha
void Update( ){
foreach(AnimationState anim in COMPONENT_ANIMATION) anim.speed = hSliderValue;
}
public void animStop( ){
COMPONENT_ANIMATION.Stop();
aniClip = Resources.Load<AnimationClip>("ANIMS/anims/_default");
COMPONENT_ANIMATION.CrossFadeQueued("_default", 0.6F, QueueMode.CompleteOthers, PlayMode.StopAll );
}
public void catchGlosa(){
Debug.Log("pegando glosa");
glosa = " _default "+Marshal.PtrToStringAnsi ( coreExecute( ) )+" _default ";
//glosa = " _default "+"ABACATE ABAJUR"+" _default ";
Debug.Log("PEGOU");
Debug.Log(glosa);
}
public void corePlay(){
Debug.Log("ReadFromDLL");
Debug.Log( "Running on "+Application.platform ); //if( Application.platform == RuntimePlatform.OS )
animStop();
catchGlosa( );
stringPos = glosa.Split(' ');
foreach( string aniName in stringPos ){
aniClip = Resources.Load<AnimationClip>("ANIMS/anims/"+aniName);
if( aniClip ){
COMPONENT_ANIMATION.AddClip(aniClip, aniName);
COMPONENT_ANIMATION.CrossFadeQueued( aniName, 0.6F, QueueMode.CompleteOthers );//0.4
COMPONENT_ANIMATION.RemoveClip( aniName );
}else
foreach(char letter in aniName)
COMPONENT_ANIMATION.CrossFadeQueued(""+letter, 0.6F, QueueMode.CompleteOthers);
}//foreach string aniName
aniClip = Resources.Load<AnimationClip>("ANIMS/anims/_default");
COMPONENT_ANIMATION.AddClip(aniClip, "_default");
}
public void animPlay(){
COMPONENT_ANIMATION.Stop( );
Debug.Log(glosa);
stringPre = " _default "
//+"BANQUETE BAR BARALHO BARBA BARBANTE BARBEAR BARREIRA BARRIGA BARRIL BARULHENTO"+
+glosa.ToUpper()+
" _default ";
Debug.Log(glosa);
stringPos = stringPre.Split(' ');
foreach( string aniName in stringPos ){
aniClip = Resources.Load<AnimationClip>("ANIMS/anims/"+aniName);
if( aniClip ){
COMPONENT_ANIMATION.AddClip(aniClip, aniName);
COMPONENT_ANIMATION.CrossFadeQueued( aniName, 0.6F, QueueMode.CompleteOthers );//0.4
COMPONENT_ANIMATION.RemoveClip( aniName );
}else
foreach(char letter in aniName)
COMPONENT_ANIMATION.CrossFadeQueued(""+letter, 0.6F, QueueMode.CompleteOthers);
}//foreach string aniName
aniClip = Resources.Load<AnimationClip>("ANIMS/anims/_default");
COMPONENT_ANIMATION.AddClip(aniClip, "_default");
}
public void closedCaptions( ){ isCaptionsActive = !isCaptionsActive; }
public void changeRes(){
switch(Screen.width){
case 640: Screen.SetResolution(800, 600, false); break;
case 800: Screen.SetResolution(1024, 768, false); break;
case 1024: Screen.SetResolution(640, 480, false); break;
default: Screen.SetResolution(640, 480, false); break;
}
}
void InutilFunc(){
Destroy(ICARO.GetComponent<Animation>());
ICARO.AddComponent<Animation>();
}
void OnApplicationQuit() {
try{ Debug.Log("Finalizando: "+ coreFinalize( )); }catch(Exception e){Debug.Log(e.ToString());}
}
void onGui(){
if( GUI.Button(new Rect(10, 10, 50, 50), "TESTE") ){
Debug.Log("Clicked the button with an image");
}
}
}