Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Character or Photo Carousel (uGUI)

Discussion in 'Assets and Asset Store' started by LaireonGames, Dec 4, 2015.

  1. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Last edited: Apr 11, 2017
  2. Raspad

    Raspad

    Joined:
    Mar 15, 2013
    Posts:
    1
    Sorry ... And how to get the selected card number?
     
  3. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Hey Raspad :)

    Oh wow massive oversight on my part there! If you drop me an email with your invoice number then I can send you an updated script with the currently selected card exposed for easier use.

    Cheers!
    Jason

    In the meantime if you apply this forumla to currentPosition it will give you the index:

    Code (CSharp):
    1. int index = (currentPosition - 1) / offsetBetweenElements;
     
    Last edited: Apr 16, 2016
  4. wmaass88

    wmaass88

    Joined:
    Dec 23, 2012
    Posts:
    43
    Hello,

    Nice effect!. Just purchased and have a question: Is there a way to handle the swipe detection differently? I ask because swiping with the mouse works great but with my Acer touch monitor is isn't as responsive as I would like. I would like to be able to skip elements quickly by swiping on the touchscreen.

    Wallace
     
  5. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Hey Wallace glad you like the effect!

    Hmm.. hard one to really answer since Unity usually does a good job of linking mouse and touch events as the same thing (if you run that demo on a phone it should work the same as the mouse does).

    It might be worth making a demo on a phone to test if it works as you expect there then if so the monitor is the problem.

    If it doesn't work as you would expect on the phone or I have misunderstood let me know and I will look into it.

    If it does turn out to be the monitor then you might need to look into handling the touch events manually and just feeding the data into the effect as though its the mouse but I doubt you would need to do that, probably just end up as something you spend forever doing to only achieve the same effect!

    Sorry I couldn't be more helpful I don't have one of those devices to test on :)
     
  6. susraj123

    susraj123

    Joined:
    Jan 10, 2017
    Posts:
    5
    How do you set the initial position ? Having current position (default to zero) is not taking effect.
     
  7. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Not sure what you mean sorry! Are you trying to set a different backing as the first one instead of the middle (middle should be the default).

    Also not sure what you mean about its not taking effect. Any chance of a video?
     
  8. susraj123

    susraj123

    Joined:
    Jan 10, 2017
    Posts:
    5
    When I start the carousel, it's taking me to a middle item (ex: M) instead of A/Z.
     
    Last edited: Feb 10, 2017
  9. susraj123

    susraj123

    Joined:
    Jan 10, 2017
    Posts:
    5
    Found the function called JumpToView to fix it... hope that's the way to go!
     
  10. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    I think it is! I am middle of a game but will check when i finish (about 10 mins)
     
  11. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Yup JumpToView is indeed the right method to go with :) Need anything else let me know!
     
  12. susraj123

    susraj123

    Joined:
    Jan 10, 2017
    Posts:
    5
    That's it. Thanks for quick reply!
     
    LaireonGames likes this.
  13. susraj123

    susraj123

    Joined:
    Jan 10, 2017
    Posts:
    5
    How to setup the carousel to auto rotate?
     
  14. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Again not 100% sure I know exactly what you mean but I am guessing you mean you want it to scroll by itself?

    For that you will need to make an external script that knows to stop once the player starts interacting with carousel. What you are basically going to do is have it animate the currentPosition variable. In the example with ten elements you will want to animate it from 5.5 to 1 and then in reverse, if you have more than that just drag that value in the editor, it will lock to its min and max, off the top of my head I would imagine its going to be from 1 to (number of screens / 2) + 0.5

    You can use a TransitionalObject to run the animation, but youwill have to write some code to figure out when to stop it, how long to wait before restarting etc.

    Hope that helps!
     
  15. ScareCrow95

    ScareCrow95

    Joined:
    Apr 5, 2016
    Posts:
    4
    Hey, I just bought the package and getting this error:


    NullReferenceException: Object reference not set to an instance of an object
    TransitionalObjects.MovingTransition.Transition (Single transitionPercentage) (at Assets/Laireon Games/Simple Transitions/MovingTransition.cs:94)
    TransitionalObjects.BaseTransition.Transition () (at Assets/Laireon Games/Simple Transitions/BaseTransition.cs:221)
    TransitionalObjects.BaseTransition.SetToPercentage (Single percentage) (at Assets/Laireon Games/Simple Transitions/BaseTransition.cs:424)
    TransitionalObject.SetToPercentage (Single percentage) (at Assets/Laireon Games/Simple Transitions/TransitionalObject.cs:511)
    LaireonFramework.CarouselElement.UpdatePosition (Single currentPosition, Single finalWidth) (at Assets/Laireon Games/Character Carousel/Scripts/CarouselElement.cs:38)
    LaireonFramework.CharacterCarousel.Update () (at Assets/Laireon Games/Character Carousel/Scripts/CharacterCarousel.cs:174)
     
  16. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Hey ScareCrow,

    Hmm.. I don't see this in the demo scene so its probably something you have changed in your project. Try and check the demo scene (or re download from the store to get a fresh copy) and see what you changed.

    In this particular case what has happened is one of your transitions has been deleted, e.g the part that either moves, scales or changes the colour of your carousel element. The problem should be in the 'Element' prefab.

    Cheers!
    Jason
     
  17. ScareCrow95

    ScareCrow95

    Joined:
    Apr 5, 2016
    Posts:
    4
    Imported it inside a different project, attaching the error image below. I am using unity 5.4.4f1
     
  18. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Sorry I can't recreate!

    Recreating on my side: https://drive.google.com/open?id=0B0-9u0TALF10Q2gxZ3VkSzExTEU

    Although I am using newer versions of Unity but I don't think this would make a difference since this package was made using a much older version of Unity and updated from there.

    You can also try hitting the download button instead of import to download a fresh copy in case your store download is corrupt.

    If it still doesn't work if you could take a video of your importing the package I might be able to spot something. If not then a screenshot of your 'Element' prefab might shed some light on what is going on
     
  19. ScareCrow95

    ScareCrow95

    Joined:
    Apr 5, 2016
    Posts:
    4
    will do, the element prefab is empty for me which is really weird
     
  20. stinky1

    stinky1

    Joined:
    Jun 1, 2017
    Posts:
    4
    hi laireaon

    this is a great asset but we are wondering if there is any way that you can make it loop so you can keep swiping in one direction and it just goes back to the start.

    kinda got it working by changing
    Code (csharp):
    1.  
    2.             #region Max and Min Caps
    3.             if(currentPosition > 1 + ((screensToSpawn - 1) * offsetBetweenElements))//if on the last screen
    4.                 currentPosition = 1 - ((screensToSpawn - 1) * offsetBetweenElements);//cap at max
    5.             else if(currentPosition < 1)
    6.                 currentPosition = 1;//cap at the min
    7.             #endregion
    8.  
    changing to a minus appeared to help when going in one direction but I think I'm missing the other way

    maybe you have an idea?

    best regards

    stinky
     
    Last edited: Jun 7, 2017
  21. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Hey Stinky :p

    Glad you like it :D Hmm.. I suspect there is no easy solution for this and I would need to code in this circumstance specifically but I am happy to do so. I'll try and give it a stab tonight and let you know how it goes (still stuck in my 9-5 atm)

    Cheers!
    Jason
     
  22. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Alright yeah its a bit easier said than done. I could easily setup a system were the elements spin in a circle but that is not an ideal solution. E.G if you only have 5 characters then you probably will only see one at a time and not be able to interact with them. Or if you have 100+ then there will be too many on screen at once and look crowded.

    Basically the number of characters you have would dictate how clean and crisp your animation is which is not ideal.

    So what I will need to do is fairly complex, have a central book section similar to what already exists but have everything else behave differently once they are off screen and recycling. Or to have an animation where screens leave one side and re-enter at the other as your scroll.

    Currently I am pretty busy on a very late update to my minecraft engine so I am going to leave this until that update is finished and come back to it. It's on my to do list for once its done but if you don't hear anything in a week feel free to give me a prod and I'll look into it again
     
  23. stinky1

    stinky1

    Joined:
    Jun 1, 2017
    Posts:
    4
    cool dude :D

    so I think what you mean is if its going in one direction instead of piling the elements up you send them to the stack on the other end - as long as it knows which direction its going which is easy, you know which end to move the card.

    I'll post up a little hack if I can find a way to do it in the meantime :)

    stinky
     
  24. stinky1

    stinky1

    Joined:
    Jun 1, 2017
    Posts:
    4
    here's the ghetto way, but it jumps at the loop (obviously)

    Code (csharp):
    1.  
    2.             #region Max and Min Caps
    3.            if(currentPosition > 1 + ((screensToSpawn - 1) * offsetBetweenElements))//if on the last screen
    4.                 JumpToView(0);
    5.                 //currentPosition = 1 + ((screensToSpawn - 1) * offsetBetweenElements);//cap at max
    6.             else if(currentPosition < 1 )
    7.                 JumpToView(screensToSpawn);
    8.                 //currentPosition = 1;
    9.             #endregion
    10.  
     
  25. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Exactly yeah :) It was just something as I looked at I realised its not something I should rush since there are a few ways to go about it:

    Could have cards leaves the left side of the screen and enter on the right (just move straight horizontally)
    Could have cards rotate in a circle so they spin out of view behind the camera
    Could fade out on the left and fade in on the right
    Could shuffle behind the existing views like a pack of cards
    Could be looking at a circle of the cards and your spinning them like an album view

    I will probably start with one and add the others slowly over time so shout now which one sounds coolest!

    I have taken a day off on Friday to get caught up with my other work so I am hopeful I can find time on the weekend to get started on one of these
     
  26. stinky1

    stinky1

    Joined:
    Jun 1, 2017
    Posts:
    4
    Case one sounds great to me - solves my issue but as a feature I can see you may want to make some other options available for devs :)
     
  27. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Cool :) I will make a point of finding some time today to take a look at it, that one is probably easiest to do thankfully!
     
  28. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
  29. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173
    Demo scene doesn't show anything ...
    Unity 2017.2.0f3
     
  30. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Hmm.. that's a bit strange, do you see any errors? Might be worth deleting the package and re downloading from the store
     
  31. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173
  32. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Aaand did you try deleting and re-downloading?
     
  33. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173
    Yes. But no change. Nothing on screen. (unity 2017.2.0f3)
     
  34. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Alright hmm.. I just checked fresh copies from the store on a couple different Unity versions (.1 and .3b) so I doubt its anything to do with that version. All we can really do then is debug and check all the basic stuff. E.G

    Are you opening the scene at the path: Assets\Laireon Games\Character Carousel\Scene\Character Select Carousel
    Do you see any of the tutorial text like is in the web demo
    Does the scene look different from a default one (I use a dark skybox in it)
     
  35. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173
    Nope (unity 2017.2.0p1). No errors log in console after run.

    But i get warnings at scene loading
    1) Assets/Laireon Games/Common/ParralaxItem.cs(7,20): warning CS0649: Field `ParralaxItem.minDirection' is never assigned to, and will always have its default value

    2) Assets/Laireon Games/Common/ParralaxItem.cs(8,20): warning CS0649: Field `ParralaxItem.maxDirection' is never assigned to, and will always have its default value

    3) Assets/Laireon Games/Common/Editor/GUIHelper.cs(103,30): warning CS0618: `UnityEditor.EditorGUIUtility.LookLikeControls()' is obsolete: `LookLikeControls and LookLikeInspector modes are deprecated. Use EditorGUIUtility.labelWidth and EditorGUIUtility.fieldWidth to control label and field widths.'


    Hope this help !
     

    Attached Files:

    Last edited: Nov 14, 2017
  36. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Asking what seems an obvious question, did you click play? The demo builds during run time
     
    Last edited: Nov 23, 2017
  37. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173
    YES Clicked play
     
  38. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Debugging anything is about checking the obvious mistakes, questions like this are important....

    Ok I think I need to start sending debug packages, if you send me an email to support@laireongames.co.uk with your invoice number then I can send an update to see what is going on
     
  39. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173
  40. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    173
    I found the (little) bug in the demo scene: missing Initialise() call in CharacterCarousel.cs

    I added this line of code and all is ok.

    public void Start() {Initialise();}
     
  41. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Ah cool glad its all working now :)
     
  42. Sednari

    Sednari

    Joined:
    Mar 18, 2015
    Posts:
    1
    Hello.
    Firstly, I have just updated the Full SciFi UI package to a new install on Unity 2017.2. I was pleasantly surprised to see this carousel asset now included in the package I already owned.
    I have the same issue as above. The demo scene for the Carousel failed to work.. As above there was no errors.
    Using the solution posted above adding public void Start() {Initialise();} to the CharacterCarousel.cs it then worked.

    Perhaps you could update the Full SciFi UI package with that line.
     
    LaireonGames likes this.
  43. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Hey,

    Ah oops thanks for that I will get it updated as well!
     
  44. Romello

    Romello

    Joined:
    May 17, 2018
    Posts:
    2
    I just purchased your character select carousel asset and I have a question. How can I edit the carousel elements individually? For example, when I press play in the sample scene, the Elements (aka characters) for the sci fi carousel are instantiated. They disappear when I exit play mode and I don't know how to find where I can edit the properties of the instantiated Elements(aka characters) individually, so when I press play the Elements (aka characters) have the properties and stats I want them to have.

    Hopefully you can help me out with this, I am pretty frustrated trying to figure this one out. Maybe there is a tutorial on this asset somewhere, but I couldn't find one yet. Thanks
     
  45. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    Hey Romello,

    There is an example of how to do this in the script called: ExampleElement.cs :)

    It uses different sprites (the variable 'characterImages') to show the different screens but you could modify it to accept prefabs instead and instantiate entirely different screens if needed.

    Hope that helps!
     
  46. Romello

    Romello

    Joined:
    May 17, 2018
    Posts:
    2
    @LaireonGames Could you please post an example code on how to edit the ExampleElement.cs to accept prefabs? I tried but failed :(
    All I want is to be able to use a different prefab for every character. I don't have many characters in my game and I like to make easy modifications to the prefabs when convenient
     
  47. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    So first change the sprites line to this (This is still within ExampleElement.cs):

    public GameObject[] characterImages;

    This will now let you drag in your prefabs. Then replace these lines:

    if(index < characterImages.Length)//check if you added more screens but not more images
    characterImage.sprite = characterImages[index];//an example to show chanaging individual character images

    With:


    GameObject temp = Instantiate<GameObject>(characterImages[index]);//spawn your prefab
    temp.transform.SetParent(transform);//parent to this object
    temp.transform.localScale = Vector3.one;
    temp.transform.localPosition = Vector3.zero;


    Please note, this code was written here and not tested! Chances are it will have spelling mistakes, this gives you a rough idea of how to work with prefabs though. It sounds like your new to Unity or coding if your struggling with prefabs, might be worth playing with some of Unitys tutorial demos, they are a pretty good starting point :)
     
  48. deiong

    deiong

    Joined:
    May 24, 2013
    Posts:
    79
    hi, i am making a board game, and i plan to have cards at the top most part of the screen that will scroll through and display the card coinciding with the current players position so as to know where you are in the board. i don't want a user to be able to interact with it other then to click on current selected card to show current facts of the location they are on. they wont be able to scroll manually. is this possible with this asset?
     
  49. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    429
    hey,

    It wont have that functionality out of the box but should be very easy to do if you have some basic coding knowledge. If you head to CarouselElement and comment out the last 3 functions (they are in a region called drag events and named accordingly) then the user wont be able to interact with them.

    Then to show information on click you will want to keep the last event, OnPointerClick but delete the existing line that makes the carousel jump to replace it with whatever you have planned to show the extra info
     
  50. deiong

    deiong

    Joined:
    May 24, 2013
    Posts:
    79
    thanks for the info. so it wont be hard to set the position of the carasoul, and also the size?