• Build Level selection screens, image galleries, scrolling credits and more (Fully working examples included)
• Works with touch and mouse input
• Works at every angle
• Includes versions for Unity iPhone 1.7, Unity 2.6 and Unity 3
Watch the video-tutorial and try the webplayer-demohere <<< (GameAssets.net)
Looks awesome. Seems like I don’t have to finish/debug my custom gui for my upcoming game
Quick question: Is the upcoming GUIKit001 a bundle of GUISkin001, GUIComponent:Swipecontrol and some additional stuff? I want it all - just not sure if it is better to wait for the complete GUIKit001 in order to make sure I really get it all?
SwipeControl and GUISkin001 are both used by the GUIKit and will thus be included in full. GUIKit001 should be available at the end of next week! (Still working on a bit of video documentation…)
Please don’t hesitate to send feedback: support@gameassets.net - is it easy enough to use? did the video explain it well enough? or just let us know what you’re doing with it!
PS: If anyone who bought SwipeControl wants to upgrade, hit me once GUIKit001 is out and I’ll give you a code so you only have to pay the difference…
Just sent out an update. We added a new script that gives a bit more flexibility for creating image galleries (and stuff like that). If you bought SwipeControl or GUIKit001, check your inbox.
Hi, I just downloaded SwipeControl and added it to my project. I want to get the same effect as the Image Display demo you included, but I want to do it with gameObjects in the scene instead of images in the GUI. Is it possible to do it with gameObjects instead of images. If so, how hard would it be. I’m finding it a little hard to understand how it all works. Is there any documentation for it?
Wrote up a bit of documentation for building your own scripts to work with SwipeControl (I’ll include this in the next update)
A) Setting up SwipeControl
You might choose to set up some variables of SwipeControl in your script instead of entering the values in the inspector. (The reason might be that you want to position it in a certain way, for example.)
skipAutoSetup = true; //Usually Setup() will be called in Start, this skips it, so you can apply your changes and call Setup() manually once you’re done currentValue = 2; //the current rounded value - this is also the value that it’s at before it starts startValue = 5; //this value gets applied when Setup() is done, so setting currentValue to 2 and startValue to 5, will make it scroll from position 2 to 5 in the beginning. maxValue = 10; //max value, currentValue can’t get higher than this SetMouseRect(new Rect(0, 0, Screen.width, Screen.height)); //Your clicks/touches have to start inside this Rect to register with SwipeControl. In this example we use the entire screen. (enable the debug checkbox at the bottom of the inspector to have a box drawn around your Rect) clickEdgeToSwitch = false; //We don’t want the user to be able to click the edges of the screen to move back/forward - only swiping will be possible partWidth = Screen.width / maxValue; //partWidth is the amount of pixels you have to move the mouse/finger so that the currentValue increases/decreases by one. In this example we make it dependent on the Screen.width and the given maxValue, so that a swipe from one edge of the screen to another will scroll through all possible values. - Set this to the width of your GUI-image if you want it to move with your cursor/finger exactly. (You can set this to a negative value to invert the direction of the swipes) Setup(); //now we call Setup() and this starts SwipeControl.
B) Working with values
Now comes the fun part! Once SwipeControl is running, you can use its values to do interesting stuff. (Move around GUI-elements, 3D objects, zoom cameras, etc. - you name it.)
You’ll mostly work with these 2 values:
smoothValue is a float that is easing towards the selected value. - use this to move/manipulate your GUI/3D objects/etc. currentValue is an integer that holds the currently “selected” value. - use this if you want to know the current selection
For example:
function Update() {
//this example assumes you have a reference to SwipeControl in swipeCtrl
transform.position.x = 22.5 + 10.0 * swipeCtrl.smoothValue; // if smoothValue is at 6.85 your transform's x-position will be set to 22.5 + 10.0*6.85 = 91.
}
Check out the included examples for more complex usages!
I have SwipeControl OrientationControl.
I can get OrientationControl to rotate my 3D scenes, but is it possible to use it to rotate the example scenes (eg. the scene named ‘Swipecontrol’) that come with SwipeControl itself?
If not, how would I go about correcting orientation of the example scenes (which Apple requires)?
@jingato: Sorry if this was a bit too generic. Here’s an example! Just download the attached unitypackage and open the scene called 3DObjects. - You have to have the SwipeControl script in your project for this to work as it’s not included in the unitypackage.
The Example3DObjects script works with any number of objects, just add them to the array. they will be spaced out according to the distance between minXPos and maxXPos. The selected one is being moved up a bit. Here’s what the (admittedly rough) example looks like:
@keeprighton1974: It’s actually quite simple. To make the ImageDisplay script compatible with OrientationControl, go to its OnGUI() function and delete (or comment out) the entire // GUI MATRIX section and then replace it with this:
The ImageDisplay script will now no longer do its own matrix stuff, but will use the matrix provided by OrientationControl and assign that same matrix to SwipeControl as well!
@col000r : Thank you very much. I didn’t expect you to write a script for me, but that was very helpful! It works awesome and I think I have a better understanding now too. I think the most I was doing wrong was the stuff in the update.
With the SwipeControl menu (I’m using the SwipeControl example scene), what is the intended method of selecting the desired item?
The example shows 5 items 001 to 005, but after reading thru the scripts I cant find a point where I would insert my code to load the next scene.
The most natural gesture would be to double-tap on the icon - is this what was intended? I can’t see any existing point in the swipecontrol javascript where this check takes place.
Any help is again very much appreciated.
Sorry to keep running to you with any little problem!!
@keeprighton1974 : What I did was to create a button down below that says “select”. Then you can can call whatever function you want and pass it the swipe controls current value.
Yes, i reckoned on that but didnt want to ruin the clean look of the interface. I think i will do as you’ve done - i can always try something different as my skills improve!
@col000r: Hey, I’ve been playing with and customizing that script that you so generously wrote up for me and I’m running into a problem that is stumping me. The problem is with the space between each of the items. It seems that the more items that I add to the array, the closer together the items get, and they begin overlapping. If I increase the variable xDist it them spaces them out correctly, but then everything slides much faster than before. I can’t figure out how to fix this. I need to be able to increase the distance but have them still slide at the same speed.
I was wondering if you could take a quick look at what I have and see if you can tell me what I’m doing wrong. I’d really appreciate it
Thanks
-John
using UnityEngine;
using System.Collections;
public class SlideMenuItems : MonoBehaviour
{
private Transform thisTransform;
private SwipeControl swipeCtrl;
public Transform[] obj = new Transform[0];
public float maxXPos = 12; //max x position of the camera
private float xDist; //distance between camMinXPos and camMaxXPos
private float swipeSmoothFactor = 1.0f; // 1/swipeCtrl.maxValue
private float rememberYPos;
private Vector3 newPos;
public int currentValue;
public int startValue;
public bool clickEdgeToSwitch;
public bool debug = false;
private float objPosOffset;
public float top;
public float bottom;
private float height;
// Use this for initialization
void Start()
{
thisTransform = gameObject.transform;
}
public void addWorlds()
{
newPos = obj[0].position;
xDist = maxXPos;
if (!swipeCtrl) swipeCtrl = gameObject.GetComponent<SwipeControl>();
height = obj[0].localScale.x;
Vector3 objPosition = obj[0].position;
Vector3 objTop = Camera.main.WorldToScreenPoint(new Vector3(objPosition.x, objPosition.y + height / 2, objPosition.z));
Vector3 objBottom = Camera.main.WorldToScreenPoint(new Vector3(objPosition.x, objPosition.y - height / 2, objPosition.z));
float objHeight = objTop.y - objBottom.y;
swipeCtrl.skipAutoSetup = true; //skip auto-setup, we'll call Setup() manually once we're done changing stuff
swipeCtrl.clickEdgeToSwitch = clickEdgeToSwitch; //only swiping will be possible
swipeCtrl.SetMouseRect(new Rect(0, Screen.height - objTop.y, Screen.width, objHeight)); //entire screen
swipeCtrl.maxValue = obj.Length - 1; //max value
swipeCtrl.currentValue = startValue; //current value set to max, so it starts from the end
swipeCtrl.startValue = startValue; //when Setup() is called it will animate from the end to the middle
swipeCtrl.partWidth = Screen.width / swipeCtrl.maxValue; //how many pixels do you have to swipe to change the value by one? in this case we make it dependent on the screen-width and the maxValue, so swiping from one edge of the screen to the other will scroll through all values.
swipeCtrl.Setup();
swipeSmoothFactor = 1.0f / swipeCtrl.maxValue; //divisions are expensive, so we'll only do this once in start
rememberYPos = obj[0].position.y;
top = objTop.y;
bottom = objBottom.y;
}
// Update is called once per frame
void Update()
{
for (int i = 0; i < obj.Length; i++)
{
newPos.x = i * (xDist * swipeSmoothFactor) - swipeCtrl.smoothValue * swipeSmoothFactor * xDist + thisTransform.parent.position.x;
objPosOffset = 1.0f * (1 - Mathf.Clamp(Mathf.Abs(i - swipeCtrl.smoothValue), 0.0f, 1.0f));
}
currentValue = swipeCtrl.currentValue;
}
}
@keeprighton1974: have a look at the code in SwipeControl - for the mouse there’s one part that checks if it’s a swipe or a click (basically it checks if you moved more than x pixels between mousedown and mouseup) - you could probably refacture that to work for touches as well. If you need more pointers, I can give it a look when I’m back in the office.
@jingato: without having tried your code yet: it sounds like you need to change the way you set swipeCtrl.partWidth - this is the amount of pixels you have to move to switch to the next full value. In your code it’s set to Screen.width / swipeCtrl.maxValue, so the higher the maxValue the less pixels you’ll need to move to go from one value to the next. You could simply set it to a fixed value to fix this. (Though you might want to make it somewhat dependent on the Screen.width if you plan to release on multiple platforms with very different screen sizes (100 pixels might be a lot on some screens and very little on others) - oh well, I’d test with a fixed value first, could be good enough.)