Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

'Snippet' Management...

Discussion in 'General Discussion' started by zombiegorilla, Aug 18, 2016.

  1. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,042
    I am curious if anyone uses local snippet management tools for storing and accessing boilerplate/common bits of code/text. If so, what tools do you use? What do like or dislike about them?

    My text editor supports snippets, but they are more for code insertion, so not very good as a library. I have found a couple I like, but not perfect:
    http://snippets.me/ (cross-platform)
    https://kapeli.com/dash (mac)

    Any favorites?
     
  2. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    Resharper live templates works for me in VS
     
  3. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Oh man I made a small application a long time ago for this exact thing... I posted it on the forums somewhere, let me see if I can find it for you lol. It wasn't nothing special, just a thing I made fairly quickly. Not sure if it's even downloadable anymore. But I'll find out.
     
  4. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
  5. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,042
    Very cool! nice work, sadly, I can't use it. (I don't do winders). ;)
    I think I have found my happy tool : https://www.renfei.org/snippets-lab/

    My text editor supports snippets, but several steps to use. Overall, what I'm trying to improve my workflow. Currently I have "tools" project that is nothing but tools / utilities / helpers that I use often. I'll copy them into new projects, and try to only mod them in the tools the projects, so I don't multiple versions. But it's getting big. And often I'll figure out way to do something that I don't want to figure out again in the future if possible, but often need it in different way. (shaders/mesh/gen/animation).

    I play a LOT, and I make a lot of unrelated tools and methods, I am getting to the point where I sometimes I can't even recall what the context was. This started, because the other day, I spent nearly an hour looking for some code I wrote a year ago for rotating uvs smoothly based on a moving target. Couldn't remember why I did it, or for what project (or where it lived -local, remote, archived). And couldn't recall any unique bits of it do an effective search. Ultimately, I could have re-written from scratch in less than an hour, but still wasted and annoying time.

    My thought is that if have a "snippet" database, kinda like pastebin, but deeply integrated into the OS, uber-secure and syncable. And anytime I spend significant time figuring something out or recognize that I could use it in the future, quickly post it in the library, and easily find it later. That is the hope anyway.

    --

    I am also interested in any thoughts that folks have on this in general, besides just using a tool. How do folks deal with avoiding reinventing (personally) large and small wheels?
     
  6. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @zombiegorilla : Thanks man, I think I may re-create it again: lost interest in it when the Asset Store didn't want to approve it: well they didn't deny it - just sat in submission for months and finally someone turn it down without even a notice. But perhaps I need to just make it a separate thing that can be used for any engine in general. No idea how to get a Visual Studio App to work on Mac's (sorry) lol. Love my Windows haha.

    And yeah I completely here you on that. But i'm the opposite - unless it's some major big system E.G. - 50,000 lines of code in various classes, I'd rather remake something, just to keep it spruced up in my head to not face situations where I wonder why I done something, etc. But still occasionally once in a blue moon I run into some old code and ask wt-beep I did something for lol.
     
  7. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,042
    Same here. I prefer that as well. Mainly that is why I am leaning toward snippets. Rather than carry over whole classes or scripts, just being able to find something that I had figured out once before (methods, algorithms, etc). Also a big problem I run into a lot is editor tools. The documentation is so limited, that often my solution will come from an obscure comment after 50 googles or just guess and check. It can be very difficult to re-find that information. ;)
     
  8. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Haha I've been in them situations before, again not often, but does happen.
    I love to make editor tools, not really much different than anything else.

    Just a slightly different way things are done. I stand my ground on this one, something I tell a lot of new comers, and I've noticed this (nothing to do with Editor Tools btw). But honestly in my opinion I've found my self 95% of the time re-using the same type of methods over and over and over again.... Okay I want to walk, make my rigidbody controls.
    Okay I want my enemy to walk forward to a way point, then do either (depending on the game) a AddReleativeForce or transform.Translate or Slerp/lerp for missile locking, etc.

    Pretty much I keep things as simple as they can ever be, if I can make something lets say 10K lines of code and can find a way to drop it down to 2500 lines that does exactly the same thing, I will do it no matter how long it takes. Because to me, optimized code is a gorgeous piece of art that not many people do. A lot of people I know put in a bunch of float this,float that, running for(int i = 0, i< 3543543543, i++) crap everywhere in the update, like omg burn their game to the ground for such crap lol.
     
  9. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    sublime snippet ftw!
     
    tiggus likes this.
  10. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,042
    In general, editor tools aren't that too bad, more that handles that are pretty weak on the docs.;)

    Yea, I'm all about the clean and efficient code. For editor tools, I am bit less. I like to make them look good and fast to use, but am fine with a little messiness under the hood. As they are a means to an end. Also since they are not part of the project, I have use lot of base editor classes/interfaces. Some are very heavy, and don't use 75% of them in any given tool, but make it really fast to spin up new tools.
     
    landon912 and Martin_H like this.
  11. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @zombiegorilla : I hear you on that.

    It's just a personal preference of mine to make code look good, makes me feel good about my self. At times though I have slopped some code together because at the time I just didn't feel like doing it lol. And yeah a lot of my stuff, even asset items I've made, never use them. They were all just random ideas I came up with because I figured there would be a need LOL... I no matter what it is, prefer to still re-make things as it gives more control over the situation I am in.

    I wonder if I still got my Editor tool that can replace Substance painter and stuff... It was partially working, just got occupied on other things lol.
     
  12. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Very poorly in my case. It's usually not code related (I don't code that much and 95% of it is always in the current big project), but rather textures, 3D models and other graphics stuff. So far I don't have a really good system to archive such stuff and find it again :(. Keeping things organized isn't my biggest strength ^^.

    Regarding snippets I'm not sure how much they would really help my. Probably my number 1 source of time consuming to find bugs is copy-pasting lines of code and forgetting to make 1 or 2 of the needed changes to the code. I really should stop that and type out everything. I'm pretty sure it would save me time in the end.
     
  13. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    now that github private repos are unlimited I find myself storing just about everything there. I hadn't done it yet with my sublime snippets but now that I am thinking about it this is a great idea.