Author Topic: Drag Panel Page  (Read 13914 times)

Alex

  • Guest
Re: Drag Panel Page
« Reply #15 on: August 06, 2012, 02:49:39 AM »
Hi again,
I update my ngui to the last version.
can you tell me please the steps that i need to take in order to make it work?
Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Panel Page
« Reply #16 on: August 06, 2012, 01:38:25 PM »
All you need to do is attach the script you see on the UIGrid object in that example. I tried to keep it simple. :)

Alex

  • Guest
Re: Drag Panel Page
« Reply #17 on: August 07, 2012, 05:12:24 AM »
Hi again,
I think you don't understand what i'm trying to achieve.
let me explain again.
take a look at this picture:
https://dl.dropbox.com/u/65967478/Level%20Selection.png

this is a level selection system.
the numbers represent the level numbers.
the user press anyware inside the pink frame and start dragging.
the pink frame is what the user can see so the interaction is made in this frame.
the numbers is scroll left/right when the user is dragging so if the user
want to play some level he need to drag untill he see its level come inside the frame.
all this work fine for me at this point.
the problem is this:
When the user release his finger, i want the numbers to be in reasonable present in the pink frame(what the user see).
so for example PHASE 1 is the correct way but PHASE 2 is really bad.
When the user release his finger i want the group numbers to be in the correct view.
can you see the problem?

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Panel Page
« Reply #18 on: August 07, 2012, 12:24:08 PM »
I understand what you're trying to achieve.

What you need to do is group widgets a certain way. Instead of having ALL your widgets be children of UIGrid, you need to group with into "pages". For example, first "page"  is a game object underneath your UIGrid, called "Page 1". Its children are 1, 2, 3, 4, 5, 6, 7, 8, 9. Second page, game object called "Page 2", and its children are 10, 11, 12, 13, 14, 15, 16, 17, 18.

Each "Page" needs to have its position be directly in the middle of the group of widgets.

Alex

  • Guest
Re: Drag Panel Page
« Reply #19 on: August 07, 2012, 01:42:17 PM »
Hi,
This is very very bad for me really.
why there is no simple way to do this for example to add some functionality to the dragable panel
with constraint vectors so te user set in which vectors positions the whole window should be clamp
upon finger release?
this is a much better way to do it.
i can't think of changing my project now it's ready to publish i just need to solve this issue.
please do something about it.
this feature will safe time and will make ngui much better.

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Panel Page
« Reply #20 on: August 08, 2012, 01:28:47 PM »
How shall I put this lightly...

I'm not here to do your work for you. The changes I add to NGUI affect thousands of developers, and if I was to do specific examples for every single developer that needed them, I'd still be doing that a hundred years from now.

I answered your questions, I created an example for you, but what you seem to want is for me to do the work for you, and I'm sorry -- I have no time for that. Use your own development skills and modify what you need to get the result you want.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Panel Page
« Reply #21 on: August 08, 2012, 05:42:00 PM »
The only thing people will see from reading this post is how you seem to assume that you buying NGUI means that you own my development time and get to demand things of me and tell me what to do. Throughout this entire thread, I've been nothing if not polite with you, but you insist on being a dick.

Buying a package on the asset store is not automatic I.W.I.N. button, as you seem to assume. Each package makes your workload less -- but it does not -- and cannot -- eliminate it entirely.

As for EZGUI... if you found NGUI to be too difficult for you, I've got news for you...

But enjoy it. :)

I'm sure Brady will be happy to do all your work for you.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Drag Panel Page
« Reply #22 on: August 09, 2012, 07:13:13 AM »
Hey Aren, I'm making this new gui for a game I'm working on. Could you do it for free please, that would be great.
 ::)

Alex, instead of demanding answers, try doing some programming.

Make container GameObjects that represent a Column in your grid, add the individual level buttons to the containers, that way you can easily populate a UIGrid with your levels.

Then you can make the draggablepanel center on a container object with the tool s you've been presented with.

Alex

  • Guest
Re: Drag Panel Page
« Reply #23 on: August 10, 2012, 05:21:37 PM »
Hi,
I did some changes to my gui project.
here is the code that build the prefab items:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class CLevelSelectionBuilder : MonoBehaviour
  5. {
  6.        
  7.         public int totalLevels;
  8.         public GameObject itemsParent;  //the parent of all itemLevel(s)       
  9.         public GameObject itemLevelPrefab;      //itemLevel
  10.        
  11.         public GameObject page1;
  12.         public GameObject page2;
  13.         public GameObject page3;
  14.         public GameObject page4;
  15.        
  16.         void Start ()
  17.         {
  18.                 CUtility.ValidateNextLevel(); //make sure the relevant level is opened.
  19.                 totalLevels = CUtility.totalLevels;
  20.                 CreateItems( new Vector3(-345f,188f,0f),totalLevels);
  21.         }
  22.        
  23.         void CreateItems( Vector3 startPivot, int totalLevels )
  24.         {
  25.                 int maxPerSet = 12;
  26.                 int col = 4;
  27.                
  28.                 Vector3 pivot = startPivot;
  29.                 Vector3 currentPivot = startPivot;
  30.                 //int curRowIndex = 1;
  31.                
  32.                 for( int i=1;i<=totalLevels;i++){
  33.                         if( i % maxPerSet == 0 ){
  34.                                 //set pivot    
  35.                                 CreateItem( i, currentPivot);
  36.                                 pivot = new Vector3( currentPivot.x+235f, pivot.y,pivot.z );
  37.                                 currentPivot = pivot;
  38.                         }else if( i % col == 0 ){
  39.                                 CreateItem( i, currentPivot );
  40.                                 currentPivot = new Vector3( pivot.x,currentPivot.y-213f,currentPivot.z);
  41.                         }else{
  42.                                 //set item
  43.                                 CreateItem( i, currentPivot );
  44.                                 currentPivot = new Vector3( currentPivot.x + 235,currentPivot.y,currentPivot.z);
  45.                         }
  46.                        
  47.                 }
  48.         }
  49.        
  50.         private void CreateItem( int pLevelNum,Vector3 itemPosition )
  51.         {
  52.                 GameObject page = null;
  53.                
  54.                 if( pLevelNum>0 && pLevelNum <=12 )
  55.                         page = page1;
  56.  
  57.                 if( pLevelNum>12 && pLevelNum <=24 )
  58.                         page = page2;
  59.  
  60.                 if( pLevelNum>24 && pLevelNum <=36 )
  61.                         page = page3;
  62.  
  63.                 if( pLevelNum>36 && pLevelNum <=48 )
  64.                         page = page4;
  65.  
  66.                 GameObject go = NGUITools.AddChild( page,itemLevelPrefab );
  67.                 go.transform.localPosition = itemPosition;
  68.                 ILevelItem iitem = (ILevelItem)go.GetComponent(typeof(ILevelItem));
  69.                 if( iitem!=null )
  70.                         iitem.SetItem( pLevelNum );
  71.                
  72.                 go.AddComponent(typeof(UIDragPanelContents));
  73.                
  74.         }
  75. }
  76.  

and here is how it look in unity:
https://dl.dropbox.com/u/65967478/levelSelect.png

The problem:
I start drag the panel to the left to scroll for group 2 ( level 13-24 ),when i release
the mouse,it return to page 1.
maybe it can help: page1...4 is in the same position at the build time( position 0,0,0 )
but all items are arranged in their places along the horizontal and vertical.
each item is added to its correct parent page.

Any idea what i'm missing here?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Panel Page
« Reply #24 on: August 10, 2012, 06:22:05 PM »
The last part is your problem -- all your pages are in the same position (0, 0, 0). You need them to be offset from each other instead. For example, panel 1 to be at 0, 0, 0, panel 2 -- 500, 0, 0, etc. Wherever the "center" for that panel should be.

Alex

  • Guest
Re: Drag Panel Page
« Reply #25 on: August 11, 2012, 08:50:14 AM »
Problam solved.

Thanks.