Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

CSGO Bullet Spray Editor

Discussion in 'Scripting' started by ZhavShaw, Jan 3, 2019.

  1. ZhavShaw

    ZhavShaw

    Joined:
    Aug 12, 2013
    Posts:
    121
    Hi, I'm looking for ideas on how to approach creating an editor sort of like the one for CSGO Bullet Spray.


    The idea I had was to just not touch the array editor, and display all of the positions on some sort of canvas below. Then change the color of the dots with lerp based on their position in the array. I'm just not sure how I would create such a canvas and display the dots.
     
    Last edited: Jan 3, 2019
  2. ZhavShaw

    ZhavShaw

    Joined:
    Aug 12, 2013
    Posts:
    121
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    3,646
    I like that guys solution because it uses the preview GUI pane, something I've not tinkered with.

    Meanwhile I made my own that is click-to-place, but it takes a different approach: there is presently no underlying data container, but you could easily plumb in a ScriptableObject type container that has your Vector2 list. Instead, the list in mine is just stored in the editor window object transiently.

    After you import the package below, you MAY need to re-drag the two PNG files onto the script itself (NOT an instance of the script obviously). See the comment near the Texture2D references.

    Left click to add dots, right click to remove. I'm glad you asked the question because now I worked through it and know all the fiddly bits of EditorWindows a bit better!

    For reasons of laziness mine is called SimpleDrawing. :) All the code is in the .unitypackage and here's a screencap:

    Screen Shot 2019-01-03 at 2.58.37 PM.png
     

    Attached Files:

    Last edited: Jan 3, 2019
    SparrowsNest and ZhavShaw like this.
  4. ZhavShaw

    ZhavShaw

    Joined:
    Aug 12, 2013
    Posts:
    121
    Awesome approach! Yeah, it's already annoying messing with 30+ Vector2 values in an array haha.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    3,646
    I imagine you could mash up a combination of his code and my code and end up with juuuuust what you need.

    I love the Unity Editor. So powerful. "There's an editor window for that..."
     
  6. ZhavShaw

    ZhavShaw

    Joined:
    Aug 12, 2013
    Posts:
    121
    I was thinking of doing exactly that. Using your code to generate an array into a file or scriptable object variable, then using the other guy's script to visualize the array in the editor. But before I do that:
    https://gyazo.com/07dc57634127d976283bf9ed6b36a601

    I'll have to reverse the script and repost so others can use too.
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    3,646
    Nice. Another thing I thought about was to drag and place discrete bullets at different parts, then you could go back and edit them... that's the freakin' problem with editors: "Oh if I just add this one more thing..."

    Have fun man! Looks like you're cookin' with gas now...
     
    ZhavShaw likes this.