Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411280 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 06:07:45 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsUnityPatterns.com - Scripts, tools, & resources for Unity developers
Pages: [1] 2
Print
Author Topic: UnityPatterns.com - Scripts, tools, & resources for Unity developers  (Read 8851 times)
ChevyRay
Level 2
**



View Profile
« on: September 25, 2013, 06:46:37 PM »



I just launched a site which will be a home base for me to post Unity tips, tricks, tools, extensions, and tutorials! I'll be posting lots of stuff over the coming months, and also some more tools (next up is a tile editor), so any Unity developers around here might want to check it out Smiley

Introduction Post - What the site is about, and what I have planned.

PolyMesh - Unity extension for creating 2D meshes, great for rapid prototyping!
ObjectPool - Simple to use script for managing object pools, great for reducing garbage collection.
AutoMotion - Coroutine powered motion and tweening functions.
TileEditor - Extension for quickly and easily building tile-based levels.
Signals - Designer-friendly tool for assigning events and callbacks visually in the editor.




I plan on updating it as much as I can, but I'm also looking for additional contributors to the site, both in the form of additional authors and developers who are interested in writing up postmortems of their Unity games!

Want to Write for Us? - Looking for additional tutorial authors and video authors
Submit a Postmortem - Can be a small technical slice of your game, or a whole postmortem!

Please let me know if you find any broken links or bugs in the site (or any of the tools). If you have any suggestions for what I could add, what I could write about, or a tool I could create, drop them here or email me.
« Last Edit: October 03, 2013, 07:16:00 PM by ChevyRay » Logged
Kren
Level 1
*



View Profile
« Reply #1 on: September 25, 2013, 07:11:07 PM »

looks nice, I have been trying to go into 2d pixel games in unity, the main problem is that for fast game making I need to invert some money ._. in tools..
Logged
Richard Kain
Level 10
*****



View Profile WWW
« Reply #2 on: October 01, 2013, 12:20:14 PM »

Finally took the Unity plunge, Chevy? You were one of THE names in flash development for a while.

I will definitely take a look at your new site though. I've managed to get my legs under me to a decent degree with Unity, but I'm still learning. Any advice from an experienced developer like yourself is appreciated.

Now that I think about it, I might be able to help you out with a tutorial or two. I wouldn't claim to be an advanced Unity developer, but I have been working on some projects, and I recently divided them up into bite-sized chunks. At least one of them would be a good fit for the format you have going.
« Last Edit: October 01, 2013, 03:11:18 PM by Richard Kain » Logged
ChevyRay
Level 2
**



View Profile
« Reply #3 on: October 01, 2013, 07:33:03 PM »

Richard: I've been a pretty hardcore Unity user for many years now, but yes I have. Smiley
Logged
Richard Kain
Level 10
*****



View Profile WWW
« Reply #4 on: October 03, 2013, 09:16:27 AM »

I read through your two Coroutines tutorials and really liked them. I had already started using Coroutines in some of my Unity development, but had always had a bit of trouble wrapping my head around them and how they work. The fashion in which you explain them made a lot of sense. I was especially impressed with your use of for loops inside Coroutines for time-based increments. I haven't seen anyone else use a for loop within a Coroutine in that fashion, but in hindsight it is extremely useful.

I've got a little GUI coding I'm finishing up at the moment. As soon as I'm done with that, I'm going to incorporate some of these Coroutine tricks into a lip-sync solution I had been working on.
Logged
kio
Level 0
*


View Profile
« Reply #5 on: October 03, 2013, 11:56:10 AM »

Nice site!

Question about the coroutines though - why are you not just using something like: yield return new WaitForSeconds(1337) ?

Logged
ChevyRay
Level 2
**



View Profile
« Reply #6 on: October 03, 2013, 07:09:58 PM »

Because I never use it, would rather yield on a nice clean routine that I wrote than creating a new object every time I want to do it.
Logged
Saishy
Level 0
***



View Profile WWW
« Reply #7 on: October 04, 2013, 05:01:50 AM »

Because I never use it, would rather yield on a nice clean routine that I wrote than creating a new object every time I want to do it.
Is there any kind of benchmark for that? Because I think new WaitForSeconds() is handled natively and not really creating an object every time. So it should be way faster than looping inside the coroutine.
Logged

TinyBird Games  We make tiny games!
Richard Kain
Level 10
*****



View Profile WWW
« Reply #8 on: October 04, 2013, 08:01:57 AM »

Because I think new WaitForSeconds() is handled natively and not really creating an object every time. So it should be way faster than looping inside the coroutine.

I can't really speak to the performance. I don't know which approach would provide better results. But since the "new" keyword is being used, you can be certain that an object is being created. If you want a better idea, I would check the internal structure of the WaitForSeconds class.

The benefit for me in utilizing Chevy's approach is a better understanding of how the yield keyword works in Coroutines. The majority of other tutorials throw the WaitForSeconds object at the user without properly explaining what's happening. While it can be a useful shortcut for time delays, it doesn't show you how things are working.
Logged
kio
Level 0
*


View Profile
« Reply #9 on: October 04, 2013, 10:19:28 AM »

as its an interessting topic, i wondered a little how would one profile this?

heres my naive approach:

TestWaitForSeconds: 1869ms
TestWait: 2211ms

as im just an enthusiast programmer, Im a little careful making statements - so is the use of WaitForSeconds "better/faster" eventhough it creates new objects? Or is the whole test just crap, and missing your point entirely?

Code:
using UnityEngine;
using System.Collections;
using System.Diagnostics;

public class WaitTest : MonoBehaviour
{
int iterations = 500000;
Stopwatch stopwatch = new Stopwatch();

void Start ()
{
Profile( TestWaitForSeconds );
Profile( TestWait );
}

void Profile( System.Func<IEnumerator> func )
{
stopwatch.Reset();
stopwatch.Start();
for( int i=0; i<iterations; i++ )
{
StartCoroutine( func() );
}
stopwatch.Stop();

UnityEngine.Debug.Log( func.Method.Name +  ": " + stopwatch.ElapsedMilliseconds + "ms" );
}

IEnumerator TestWaitForSeconds()
{
yield return new WaitForSeconds(1f);
}

IEnumerator TestWait()
{
for (float timer = 0; timer < 1f; timer += Time.deltaTime)
        yield return 0;
}
}
Logged
ChevyRay
Level 2
**



View Profile
« Reply #10 on: October 04, 2013, 11:33:59 PM »

You can make a topic about it if you want. I'd rather not here.
Logged
wccrawford
Level 3
***



View Profile
« Reply #11 on: October 07, 2013, 03:41:56 AM »

It's incredibly rude to hijack someone's topic instead of creating your own.
Logged
ChevyRay
Level 2
**



View Profile
« Reply #12 on: October 07, 2013, 03:51:05 AM »

Eh it's not that bad, the conversation was related, it just wasn't interesting.
Logged
wccrawford
Level 3
***



View Profile
« Reply #13 on: October 07, 2013, 08:05:39 AM »

Yeah, I guess I'm just having a grumpy day.  Sorry.  To both of you.
Logged
darkhog
Level 7
**


Dragon Agent


View Profile
« Reply #14 on: October 07, 2013, 10:31:28 AM »

One suggestion: Please put it on Asset Store. This would help greatly. I especially love Tile Editor extension. But have question:

- Will it work with Unity Free
- Can I place/remove tiles in runtime to e.g. make in-game level editor

I'm considering using it for my next game, but need answers to those questions to decide fully.

Also being able to put tiles on any plane (though I can also rotate map Wink) and more layers would be cool to have, so I can make e.g. house that has proper roof which disappears once player is inside.
Logged


Be a computer virus!


I cannot C well, so I stick with simpler languages.

There are no impossible things, there is only lack of skill.
Iso
Level 0
***



View Profile
« Reply #15 on: October 08, 2013, 12:18:03 AM »

I just found this topic by chance and I must say, these snippets are very useful.

I already had a message/event/button code but it was a total mess compared to your example. It's also opened my eyes to other things that I can do with the inspector/editor!

I have a question about your object pool though, you say towards the end, " If CreatePool() was not called, Spawn/Recycle will just instantiate and destroy objects as usual, making it really easy to toggle pooling on/off per prefab."

So what exactly is pooling and how does it differ from using instantiate?

Edit: Oh wait, is pooling that thing where to avoid lots of creating/destruction of objects, it just frees them up when you recycle so the next Spawn uses the old object?
Logged

ChevyRay
Level 2
**



View Profile
« Reply #16 on: October 08, 2013, 06:15:41 AM »

Yes, so if you use an object pool, it won't destroy the objects, it will just deactivate them. When you call Spawn() the next time, if there are any deactivated objects in the "pool" available, it will just activate one of those instead of creating a new one.
Logged
darkhog
Level 7
**


Dragon Agent


View Profile
« Reply #17 on: October 08, 2013, 07:33:48 AM »

Can you answer my questions? Last post on first page.
Logged


Be a computer virus!


I cannot C well, so I stick with simpler languages.

There are no impossible things, there is only lack of skill.
Richard Kain
Level 10
*****



View Profile WWW
« Reply #18 on: October 08, 2013, 09:30:31 AM »

The drawback to object pooling is that you have to have a set limit on how many objects are available. Once you run out of objects in the pool, you run out. When you instantiate objects in the normal fashion, there is no restriction, and no theoretical limit.

The advantage to object pooling is that limiting the number of objects insures better performance, and helps to keep tighter control over the number of instances. It can be a real boon to bench-marking, and can be used in debugging to run performance tests. While it limits the number of objects at a time, that limit is also determined by the developer, and can be adjusted based on the circumstances. Object pooling can be a great method for preventing crashes from object spamming.
Logged
darkhog
Level 7
**


Dragon Agent


View Profile
« Reply #19 on: October 08, 2013, 05:02:45 PM »

The drawback to object pooling is that you have to have a set limit on how many objects are available. Once you run out of objects in the pool, you run out. When you instantiate objects in the normal fashion, there is no restriction, and no theoretical limit.

What's wrong with dynamic pooling? Once you hit limit, "goal post" is moved and you have more objects in your pool. There would be (unnoticeable) delay with instantiating one new object to add to the pool, but once it's done, limit is increased.

The trick is then to set proper initial pool size, so it won't try to increase it at start of game (and therefore lag), but also small to not make too big memory footprint. Then, during the course of game, limit can be increased as needed.
Logged


Be a computer virus!


I cannot C well, so I stick with simpler languages.

There are no impossible things, there is only lack of skill.
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic