Home > other >  Unity3D to realize mobile phone screen effect
Unity3D to realize mobile phone screen effect

Time:09-23

Use Unity3D do a similar phone around the function of the sliding panel

My idea is that two Canvas, fingers moving first Canvas, localPosition plus mobile distance, the second Canvas also move the same distance
Don't know right, there is a great god can give you a Demo

CodePudding user response:

This kind of problem, write a try

CodePudding user response:

With it is good to touch the plugin directly, or easytouch leantouch

CodePudding user response:

 void OnGUI () 
{
If (Event) current) type==EventType. The MouseDown)
{//to record the location of the mouse to press the
First=the Event, the current mousePosition;
}
If (Event. Current. Type==EventType. MouseDrag)
{//to record the location of the mouse drag
Second=the Event, the current mousePosition;
If (second. X & lt; First. X)
{//drag the position of the x coordinate than press the location of the x coordinate of the hour, incident response to left
Print (" left ");
}
If (second. X & gt; First. X)
{//drag the position of the x coordinate is greater than press the location of the x coordinates, the response to the right event
Print (" right ");
}

Float tempX=first. X - second. X.


//control map is not removed from the screen
If (this. The transform. The position. X + tempX & lt; 640)
{
return;
}

This. The transform. Translate (new Vector3 (tempX, 0, 0));


The first=second;
}
}


The code above, on a GO, can see the effect, in the PC mobile end there are effective
  • Related