Looking to make it so that the white objects can be individually dragged onto screen and positioned by a player. Searched around and only found ways to ADD items to an inventory, which isn’t what I need. Anyone?
Nothing?
Uh. Can I ask something?
How did you make those GUI Buttons? They arent like gray, their white… how?!
And to make something so you can drag it, you should uh… posiiton the object to mouse on click, and then if he lets go, round to the closest one.
At FIRST, you should have a table of rectangles or variables of rectangles
Second, you need to have some way to tell if the box has something to drag in it, or else you may get errors
Assuming you always had object 1, you might want to do these things
Check for gui.button
if so, the text = mouse.position
if the button is clicked again while dragging,
Round to closest box
Yup
And, if you want to use my inventory/crafting system/furnace system, just ask
(Right now it does not have stacking though. :?
oh, if you wanna see mine, then here
yeah download the two links, .exe and data
Uh, some bugs:
.Makes 2 furnaces
Some thing that you cannot do:
Undo crafting
Things you need to know:
To open inventory: press i, uh, to mine dirt, get a shovel
stone
wood
wood
to craft, left click
to select in selection boxes, side click
hope ya enjoy
Findo,
Thanks for the replies! Was beginning to the Unity forum was a radiation zone.
Not sure what you’re asking about the white gui buttons thing. This is a mockup I made in photoshop in about a minute. Been using photoshop for over twenty two years, and 3ds max for over twenty.
A gui button can be whatever you make it look like in photoshop. Make a new file, whatever pixel heigh/width, it will default to white background. Put some text or whatever look you want onto it, save as png, there’s a button for unity.
For your explanation, thanks for the idea. I’m not sure my explanation was fully done, so here’s another.
I want to have those a,b,c,d,e and object1 and object2 icons at the left and bottom of my hud. When playing the game, I’d like the player to be able to say: “Hmm…I’d like to drag a copy of object1 into place, and a few of the boxes on the left…maybe D, a few C’s and an A box.”
And they would click on object 1 and drag a copy of it into the scene, likewise with the boxes. Will your system do that?
I do have a tool system, if thats what you mean.
You just right click the item in the inventory(not drag it sadly) and then use 1,2,3,4, and 5 to select where it is.
Still some bugs in it though
So It holds up a hammer if you have a hammer, a sword if you have a sword… yeah.
Yeah, this would have to be doable on mobile in super limited screensize. So pushing keys to determine ‘item a,b,c,’ etc. is out.
Just edited it, look at teh pic, and uh, its easy to change the numbers to clicking.
Hmm…interesting…any way to get that selection zone so it’s at the bottom and left side of screen? It might be useable if so…
Easily. Just change the position.
So was there something more you meant about the white squares? I’m not sure I answered your question…
And “Survival Files” download link at the bottom left of your main page is not working…
I’ve implemented the ususal drag and drop, plus the drag and drop into the environment, for the Rust clone I’m creating as part of teaching myself Unity, and it’s surprisingly simple. But it really helps to have a proper GUI solution, though, and I’ve chosen DF-GUI for that.
For each slot in my inventory, I have a SlotController which looks something like this:
// OnDragStart
public void OnDragStart( dfControl source, dfDragEventArgs args ) {
if ( slot.itemCount > 0 ) {
args.Data = this;
args.State = dfDragDropState.Dragging;
args.Use();
DragDropController.Show( this, args.Position );
}
}
// OnDragEnd
public void OnDragEnd( dfControl source, dfDragEventArgs args ) {
DragDropController.Hide ();
}
// OnDragDrop
public void OnDragDrop( dfControl source, dfDragEventArgs args ) {
if ( args.Data is HudSlotController ) {
HudSlotController slotController = (HudSlotController)args.Data;
Slot sourceSlot = slotController.slot;
Slot targetSlot = this.slot;
if ( targetSlot.isFull ) {
return;
}
string itemName = sourceSlot.FirstItem().name;
int itemsAdded = targetSlot.AddItem( sourceSlot.FirstItem(), sourceSlot.itemCount );
sourceSlot.RemoveItem( sourceSlot.FirstItem(), itemsAdded );
args.State = dfDragDropState.Dropped;
}
}
Then I also have a HUDPanel, which covers all of the first-person’s screen, but is - of course - invisible for the player. It also has a OnDragEnd() method, but is slightly different. What it does is that if I drop an item “into the world”, it will create a sack with the item(s) dropped.
That’s what I think I’m needing, toreau. In the idea I’m cooking up, a player could ‘select/drag’ from the lineup of objects and then could drag/relocate them repeatedly in the play space. I’ll compile this script and let you know if it’s working. I don’t know what DF-GUI is though, and unless it’s free and doesn’t require programming, I won’t be able to use it.
*Just looked at the item in asset store. Sorry but this isn’t an option.
My friend said his worked after 2 installations. Try again?
WAit, thats weird, I tryed… but it says it don’t exist…? Just a sec.
Fixed.