WebScript.cs
2.56 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
//Log Dir http://docs.unity3d.com/Manual/LogFiles.html
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.IO;
using System.Runtime.InteropServices;
public class WebScript : MonoBehaviour {
public static float hSliderValue = 1.1f;
public Boolean isCaptionsActive = true;
string alfabeto = "0123456789,ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static string[] stringPos = {"_default"};
AnimationClip aniClip;
public string glosa = " _default ";
GameObject ICARO;
Animation COMPONENT_ANIMATION;
void Start( ){
Application.ExternalCall("onLoadPlayer");
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.CrossFade("_default", 0.6F, PlayMode.StopAll );
}
public void catchGlosa(){
animStop( );
this.glosa = " _default "+glosa+" _default ";
webPlay();
}
public void webPlay(){
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.CrossFade(aniName, 0.6F );
//COMPONENT_ANIMATION.RemoveClip( aniName );
}else
foreach(char letter in aniName)
COMPONENT_ANIMATION.CrossFadeQueued(""+letter, 0.6F, QueueMode.CompleteOthers);
//COMPONENT_ANIMATION.CrossFade(""+aniName, 0.6F );
}//foreach string aniName
aniClip = Resources.Load<AnimationClip>("ANIMS/anims/_default");
COMPONENT_ANIMATION.AddClip(aniClip, "_default");
}
public void closedCaptions( ){ isCaptionsActive = !isCaptionsActive; }
void InutilFunc(){
Destroy(ICARO.GetComponent<Animation>());
ICARO.AddComponent<Animation>();
}
}