Public class TestSSVEP: MonoBehaviour
{
Private List
///& lt; Summary>
///the position of each square, in fact, the four picture
///& lt;/summary>
Public List
///& lt; Summary>
///stroboscopic frequency, flickering stipulated time
///& lt;/summary>
Public List
Private List
Private void the Start ()
{
Initial ();
}
///& lt; Summary>
///initializes the squares, determine the stroboscopic frequency and the position of the corresponding
///& lt;/summary>
Private void Initial ()
{
For (int I=0; I & lt; ImageLists. Count; I++)
{
StimulateInfo stimulate=new StimulateInfo (imageLists [I], stimulateFrenquencyLists [I]);
StimulateLists. Add (stimulate);
}
Foreach (StimulateInfo item in stimulateLists)
{
Thread newThread=new Thread (ChangeColor);
NewThread. Start (item);
ThreadList. Add (newThread);
}
}
///& lt; Summary>
///stroboscopic
///& lt;/summary>
///& lt; Param name="o" & gt;
Private void ChangeColor (object o)
{
# region thread to sleep
As StimulateInfo StimulateInfo stimulate="o.
While (true)
{
//ThreadCrossingHelper is a thread cross access assistant, for use in the main thread UnityAPI
ThreadCrossingHelper. Instance. ExecuteOnMainThread (()=& gt;
{
Stimulate. Img. Color=color. Black;
});
Thread.sleep ((int) (Math. Round (1.0 f/stimulate FlickerFrequency/2, 3) * 1000));
ThreadCrossingHelper. Instance. ExecuteOnMainThread (()=& gt;
{
Stimulate. Img. Color=color. White;
});
Thread.sleep ((int) (Math. Round (1.0 f/stimulate FlickerFrequency/2, 3) * 1000));
}
# endregion
# region coroutines
# endregion
}
Private void OnApplicationQuit ()
{
For (int I=0; I & lt; ThreadList. Count; I++)
{
ThreadList [I]. Abort ();
ImageLists [I]. Color=color. Black;
}
}
}
CodePudding user response:
Code thread. Sleep parameters of the unit is milliseconds yo, even if your code is no problem, the screen refresh rate also failed to keep pace with,How much is 0.075 ms converted to screen refresh rate?