Search Unity

[RELEASED] Magic Markers: Visibility for Your Invisible GameObjects

Discussion in 'Assets and Asset Store' started by syscrusher, Dec 1, 2017.

  1. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Asset Store Page: http://u3d.as/10YM

    Magic Markers is an editor extension for attaching procedurally-generated marker meshes to any GameObject or prefab. The 3D markers are visible and selectable in the Scene View of Unity during editing. Unlike 2D "billboard" icons, the Magic Markers are easy to visualize within the world space of your scene.

    Magic Markers may optionally be enabled for rendering in-game at runtime. Although this is intended primarily for testing and debugging purposes, the runtime feature can be used for special cases such as quest targets or “points of interest” on a level map or mini-map.

    Magic Markers are great for making invisible game objects visible to programmers, level designers, and play testers, or to players and modders for games with runtime level editing.

    Suggested Uses
    • Player and NPC Spawn Points
    • Patrol Way-Points
    • Designer To-Do Placeholders
    • Visible Mini-Map Markers
    • Scene and Game Manager Objects
    • Origins for Procedural Geometry
    • Empty parent GameObjects for Prefabs
    • Quest Destinations and Targets
    • Mark Particle and Sound Effect Emitters
    • Self-Identify Object with Runtime Error
    • Crafting Station & Furniture Markers
    • Teleport or Scene Load Destinations
    • 3D Replacements for Unity Gizmos
    Features
    • Procedural geometry and appearance; no texture files required.
    • Select “invisible” objects directly in Scene view; no more clicking similarly-named objects one by one in the Hierarchy to find the one you want to edit.
    • Multiple predefined marker shapes: Alert, Booth, Camera, Capsule, Circle, Cube, Diamond, Emitter, Flat, Question, X-Mark.
    • Make your own shapes as a C# script with stored vertex coordinates (in arrays).
    • Use your own low-poly mesh or Unity primitives with the Generic marker type (no materials required).
    • Included utility helps create C# source code from a Unity MeshRenderer component.
    • Marker types are stored as asset files. Reuse your marker type assets between projects.
    • Purpose-built texture-free, unlit shader included.
    • Optional wireframe accents rendered by shader (on platforms supporting SM 4.0 or higher).
    • Custom shader works on SM 2.5 and higher, gracefully adapting features to the target platform.
    • Markers can be individually controlled for in-game visibility. Deeply configurable camera selection.
    • For debugging in the Editor, or invoked from an in-game developer console, a single line of C# code can temporarily make all Magic Markers visible in-game.
    • Markers optionally follow surface contours (including terrain) as they are moved in the Scene view.
    • Change any Magic Marker's appearance dynamically with C# scripts (examples included).
    • Clean, well-commented C# and shader source code included.
    • Detailed and illustrated User Manual, video tutorials, and included example scenes. Magic Markers installs in seconds, but solid documentation will help you use the asset to its fullest.
    • No GC allocations after initialization, except for one frame when Magic Markers are dynamically modified by C# code.
    • Supports all Unity releases from 5.4.6 through 2017.2 (betas are not officially supported, but 2017.3b10 works).
    • Works in Unity Editor on Mac OSX or Windows, and in runtime on Windows, OSX, Linux, Android, and WebGL (other mobile devices and consoles probably work but are not formally supported).
    More Information


    Release Trailer Video



    Tutorial Videos



     
    Last edited: Nov 12, 2018
    theANMATOR2b and TonyLi like this.
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    This looks really useful!

    I frequently set up empty GameObjects for camera positions and stage blocking positions in the Dialogue System, as well as spawnpoints in Quest Machine and the Save Systems for UFPS and RFPS. It'll be really handy to have a nice way to visualize and select them.
     
    Teila and theANMATOR2b like this.
  3. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    I certainly hope you'll like the asset. In absolute honesty, this was originally something I made for myself. Another game engine I have worked with in the past had the green booth marker and the X marker built in, and I was surprised that Unity uses its billboarded 2D icons, which at least for me convey no sense of position in the direction of the viewport axis. Opsive's excellent UFPS asset also has a marker similar to the green booth marker, so I know I'm not the only one who wanted this.

    When nobody was selling this type of tool on the asset store, I decided to make it myself. Originally it was just the booth marker. Then I decided to add a couple of other types. From there it grew, and after I'd used my own tool for about a year in my projects, I realized I might have something that would help others as well. I demoed an early version at Unite 2016 in LA, and got some very valuable feedback from other asset developers, gamedevs, and a couple of people from the Unity team. That caused me to go back and rework the way I partitioned the configuration between "marker type" and "marker instance". The custom shader is also much improved over my original design. What I'm releasing now is the result of all of that. It cost me some delay in release, but I feel the result is a much better workflow.
     
    TonyLi likes this.
  4. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    I see a lot of uses for this. When I make paths sometimes, I need something to mark the path so I can scroll out and draw the path exactly where I want it. Also, when using UMA's, it can be difficult to make sure you are spawning in the correct places so these markers could help, a stand in for where you later want the UMA to spawn. Yes, UMA has a box or a gray person-like marker, but those all look alike.

    Would be very useful also for fixing areas where NPCs get stuck. I can place a marker wherever they get stuck, go out of play mode and fix the problem with a collider or adjusting the navmesh. With UMAs, again this is useful as they will disappear when going back to the editor.

    As Tony said, great for placing spawn points.

    Thanks for making something I did not know I needed. lol
     
    syscrusher likes this.
  5. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    This triggered a thought-association for me. When I was building the demo scene, I had a problem with those capsule "characters" failing to reach their destination because in my high-count stress testing there are simply too many capsules and not enough potential markers. They cluster around the markers, but the ones inside can't get out through the crowd, and the ones outside didn't go away because they still wanted to reach the marker. I had to build in a failsafe timer that, after a couple of seconds of being stuck, just gives up and picks the next destination.

    The reason I mention this to you, is that if you can implement some kind of timer in your NPC that detects:
    1. I am currently supposed to be moving AND
    2. I am not at my intended navmesh destination AND
    3. I have not moved more than "X" units in the past "Y" seconds
    then you could have your NPCs self-detect a lot of these problems. In that case, you have a perfect situation for runtime adding one of the exclamation mark "alert markers" at runtime using AddComponent(), or have the alert marker preattached to your prefab and just enable it when the character detects it has a problem.

    This was actually one of the anticipated use-cases for the alert marker that is mentioned in the documentation. I'm glad to see that it might be useful to someone. :)
     
  6. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    In case anyone is curious, as of Friday 2017-12-15, Magic Markers was still awaiting approval. I'm told the Asset Store team is buried with a bunch of new asset submissions right now.
     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    New assets take about 20 business days nowadays (i.e., about a month). But it might be a little longer this month because UnityScript is being deprecated. There's a December 31 deadline to resubmit any assets that contain UnityScript files, even for demo scenes. I'm sure there's a flood of resubmissions right now.
     
    syscrusher likes this.
  8. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Aw, crud. I had heard from somebody that there were a ton of submissions recently, but I didn't connect it with the UnityScript deprecation. Thanks for the connecting info; this gives it some perspective and context.
     
    Teila likes this.
  9. RuinsOfFeyrin

    RuinsOfFeyrin

    Joined:
    Feb 22, 2014
    Posts:
    785
    Very interested in this when it gets approved to the asset store.

    As @Teila said, this is something i didn't know I wanted or needed till I saw this. I see this being one of those assets that gets imported into any new project immediately because after watching the videos, it leaves me feeling like this is something that should just be part of unity.

    I took the time to read over the documentation, and i have to say it is possibly the most thorough sets of documentation I have ever seen as well.

    Good luck with the release, I think you have a future potential hit on your hands.
     
    syscrusher and Teila like this.
  10. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    It will happen! Everyone is poor anyway due to the big sale and the holiday season. :)
     
    syscrusher likes this.
  11. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Good evening, everyone! I am very pleased to announce that the Asset Store Team approved Magic Markers today!

    Here's the Asset Store link: https://www.assetstore.unity3d.com/en/#!/content/105391

    As a reminder, please don't post bug reports or support requests in the reviews. The Asset Store doesn't notify publishers of these, so you won't necessarily get a quick response. You are welcome to contact me at the support email listed on the Asset Store page, or post your questions and feedback here. I'm not so conceited to think my code is perfect, so if you find something that needs improvement, please let me know. :)
     
    TonyLi and Teila like this.
  12. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Yay! Congrats!!!

    Had to get Aynsley over to look at it on the Asset Store. :)

    Looks very good!
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    I've been using Magic Markers for a few days now. It's really useful! It has more uses (and more features) than I expected.

    This asset seems really complete, so it may be a stretch to suggest these additional features:

    1. A window that contains a list of all magic markers in the scene, with the ability to select a magic marker by clicking its entry in the list.

    2. An option to add or move markers in play mode and have the changes persist when stopping. This may be a controversial request, since we're all used to changes disappearing when stopping play mode. Cinemachine's persistent play mode changes drive me a little crazy, so I'm on the fence with this one. But it would be useful to mark problem areas that arise while playing the scene, or to tweak spawnpoint/waypoint positions in play mode.

    Just thought they might be convenient features for a future version.
     
    Teila and RuinsOfFeyrin like this.
  14. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Not at all. I'll never promise to implement every suggestion, because to do that would be to invite scope creep and code bloat, but I'll absolutely consider anything reasonable. My hope is that others find creative uses for the markers that I never envisioned.

    It's funny that you ask for that, since my promo video talks about how painful it is to have to find invisible GOs by selecting them in the Hierarchy. LOL! Still, I could see where that might be a useful feature, especially if they were sorted by the marker *type* rather than by the scene hierarchy. I wonder if this could be achieved already with the built-in search box at the top of the Hierarchy window? Please give that a try, because I think this is a feature worth considering, and one aspect of its design should be "what do we need in functionality that differs from what's built into Unity?"

    I'll add this to the Road Map list of "under consideration" features on the Bit Bucket site.

    Ah, yes, I see what you mean here. If I understand correctly, you basically want your moving GameObjects to be able to "lay eggs" that are made of Magic Markers, and have those eggs persist after the return to edit mode. Did I get that right?

    Thanks for the feedback and suggestions. These are both interesting ideas.
     
  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    It almost can, but it's not as convenient. When you apply a filter such as "t:MagicMarker" to the Hierarchy, it grays out everything in the Scene view except for the filtered objects, and it also doesn't sort by marker type. It would be nice if you could click through a list that's sorted by type, and when you click on an entry it would select that marker and focus on it in the Scene view.

    That would be nice, too. I was just thinking that it would be useful for the level designer to manually add markers in play mode using the same wizard window, and maybe also to remember the positions of markers when exiting play mode. But scratch the latter idea. Markers are often added to moving objects, and it wouldn't do to remember their play mode positions. Dropping new markers in play mode would still be useful, though.
     
    syscrusher likes this.
  16. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Interesting ideas, and thanks for the reply. I'll need some time to think about how to do these, because anything I add I want to "get it right." I'll add both ideas to the wishlist on BitBucket, and after I've had some time to ponder, I'll bring some concepts back to the forum (here) for public comment. Thanks for the feedback!
     
    TonyLi likes this.
  17. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    To those who have purchased Magic Markers so far, thank you very much! I wanted to let you know that I am working on a small update that will correct a couple of minor bugs that have been reported by users, and will improve the included examples. I don't have a firm ETA on this, but wanted everyone to know an update is coming. I do not expect any "breaking" changes, so it is safe to deploy the current version and upgrade to the new one later.
     
    TonyLi likes this.
  18. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Hey before I buy. I was wondering if magic marker works on game objects that are inactivate?
    Like they still show the marker.
    Cause all my spawners start out deactivated.
    I could tried to change how I do my spawners but I wanted to ask first.
     
    Last edited: Jan 20, 2018
  19. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    That's actually a very interesting question, and here's why: I recently noticed that Magic Markers still draw when the MagicMarker component is not enabled, which is a bug. I have fixed that in the upcoming version, so now the Magic Marker correctly respects the enabled member variable.

    I see your point about having the marker visible on an inactive object so it would be selectable, but Unity doesn't give me that level of control. If a GameObject is disabled at the object level, then none of the per-frame methods (such as Update() or OnDrawGizmos()) are called for that object. My code can't draw itself if Unity never invokes it, and Unity won't let me execute the draw functions from within other methods such as OnGUI() that are called on disabled objects.

    For your specific case, I have two suggestions:

    1. You could make an empty GameObject with a MagicMarker component (either manually or using the Magic Markers wizard) that has the same world location as your spawn object. Then make your spawn object a child of the Magic Marker object at a local transform of zero. This is backwards of the way Magic Markers normally are used, but the markers won't care. Now you can activate and deactivate your child object as you wish, and as long as the parent with the marker is always active, the marker will be drawn. The marker object has to be the parent, because otherwise deactivating your object would force the marker object to also deactivate, and again my code would never get called.
    2. Here is how I would actually do it, instead: Make your spawner object always active but then use the component-level enable/disable flag (the enabled boolean member variable) to turn the spawn functionality of that object on and off. The GameObject contains my MagicMarker script and your spawner script side-by-side, and your scene manager code enables and disables your component but leaves the MagicMarker component always on. That should do exactly what you need.
    I'm presuming in #2 that you have a spawning script of your own attached to your spawn point objects. The key fact here is that your script, then, is in control of whether it does or does not spawn something at any given time. Deactivating the GameObject that contains your script is a convenient way to prevent it from spawning, but it's not the only way.

    Let me know if that is confusing, and I'll follow up with some example code snippets.
     
  20. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    By the way, are you planning for your spawn points to be visible in the game all the time (not just for debugging), or were you referring to the markers displaying in the editor? My suggestions work either way, but I wanted to clarify the question for the sake of any followup conversation. :)
     
  21. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Actually this is why I have spawn game objects inactive right now.
    I'm using gameobjects for map locations and just what ever to organize spawns

    So my loop that loops through them ignore active game objects
    Then activates the object to activate the spawn.
    I can't figure out how to do it any other way cause each scene has it's own spawn component which has a drop down list of stuff that can be spawn for that scene.

    Code (csharp):
    1.  
    2. Spawn NPC List (active)
    3.         Map location (active)
    4.                 Spawn goblin (inactive)
    5.                 Spawn goblin (inactive)
    6.         Map location 2 (active)
    7.                  Spawn elf (inactive)
    8.                  Spawn elf (inactive)
    9.  

    I tried hard to Google how to get a component by string name but I failed when trying to turn the component into a scriptable component. I don't want to use a giant switch so idk
     
    Last edited: Jan 20, 2018
  22. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Ah, I see. Fortunately, that is very solvable, and your use-case is exactly what Magic Markers is made to do.

    For illustration, let's assume the class name of the spawn component with the dropdown list is Spawner, and that the class name of your map location objects is MapLocation. You can make all of your GameObjects active, but disable your component on the objects that should not spawn.

    So you would have a loop similar to this, running in a script attached to the top-level object (Spawn NPC List) in your example, and only that one object:

    Code (csharp):
    1.  
    2. MapLocation[] mapLocations = getComponentsInChildren<MapLocation>();
    3. for (int loc=0; loc<mapLocations.length; loc++) {
    4.    if ((mapLocations[loc]).enabled) {
    5.       // The enabled flag on the MapLocation component will indicate whether
    6.       // you should process that component or not.
    7.       SpawnObject[] spawnOptions = (mapLocations[loc]).getComponentsInChildren<Spawner>();
    8.       // Now spawnOptions is an array of the spawn possibilities at that location,
    9.       // and you can have the data members in the Spawner object store data about the creature, etc.
    10.       for (int option=0; option<spawnOptions.length; option++) {
    11.          if ((spawnOptions[option]).enabled) {
    12.             // Here we know that this specific option is enabled....do whatever you want based on that
    13.          }
    14.       }
    15.    }
    16. }
    17.  
    The code above assumes all your GameObjects are always active, but you can enable and disable your custom components as you wish to indicate their status to your other logic. As long as you leave the MagicMarker components enabled, they will remain visible as you wish them to.

    I'll also mention that this approach automatically ignores GameObject children that do not have your scripts attached. So if you need to put "other stuff" into this object tree, you can safely do that without confusing your spawn logic. :)

    Two caveats:

    First, since I don't have your scene, this is code from my brain direct to the forum and hasn't been compiled. Please forgive any syntax errors. :)

    Second, this isn't really the most efficient way to manage this kind of logic. My recommendation would be to consider using something like a ScriptableObject to contain those dropdown lists within the MapLocation script. Doing that will let you define dropdown lists as an asset file that can be shared across many map locations, and updating that asset directly in the Unity inspector will change the list of spawn options for all locations that share the same dropdown list asset. That really scales well to large projects. (ScriptableObjects are awesome that way -- in fact, Magic Markers uses ScriptableObjects to store the properties of a "type" of marker, then you deploy multiple instances of that marker type in your project.)

    The Unity folks have an excellent tutorial on ScriptableObject usage, if you haven't used them before.

    I hope you'll find this example helpful; let me know if any of what I've suggested is unclear.
     
  23. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Hmm ya the main issue is the drop down lists. If I can use the same script name for ever zone for my spawn script then that would solve everything. Idk if I wanna dig into that scriptable object idea. That seems like the answer if my lists data can be in a unique file.

    Your first idea won't work though. Cause I can't enable the spawn component since the class name is different for each scene. I could solve that though if I had a separate global spawn controller for each scene. It just seems silly though

    Interesting enough I came up with an idea while reading yours lol.
    I start with all active game objects.
    Have the spawn run inside OnEnable
    Have the spawn script ignore the first OnEnable
    Then I could just inactive the game object and re-inactive it again
    Idk if that works by setting a game object inactive and then active again in the same frame though. If it would trip the OnEnable function on the next frame or not
     
  24. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Why is your class name different for each scene? That's a very unusual design pattern. Have you considered using DontDestroyOnLoad to have a single game manager script that persists across scene loads?
     
  25. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Don't destroy on load wouldn't solve anything for me. I use it for all my UI.
    I use the asset called Odin https://assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serializer-89041
    Let's me take a string array and display it as a drop down selection box in the editor

    Each drop down is a list of choices of stuff to spawn.
    I don't know how to do better editor tools.



    As you an see each script has unique stuff to spawn on it. A new script for each Zone/scene.
    So ya if i knew how to do a drop down list where the string lists are loaded in with editor code from a file name that I can pass with a string. Then that would fix everything. Idk how to do that though.

    some of these drop down boxes are Enums
    I could just drag prefabs in I guess on stuff I want to spawn. Cause the stuff I spawn is organized in folders anyways.
    So the drop down lists are kinda a bit overkill maybe and more work honestly. Cause every new type of thing I want to spawn I have to add it to the string array. Which is more work. It does allow me delete a prefab and create a new one with out it messing up with everywhere I dragged/linked it into the inspector though. so it does give that freedom.
    So I have been considering changing over. I haven't started building my worlds yet. Just got a test zone right now

    Code (csharp):
    1.  
    2.  
    3.     public GlobalCharacters m_GlobalCharacters;
    4.    
    5.     [ValueDropdown("MobCharacters")]
    6.     public string m_MobCharacters;
    7.    
    8.     [ValueDropdown("QuestCharacters")]
    9.     public string m_QuestCharacters;
    10.  
    11.     [ValueDropdown("QuestItems")]
    12.     public string m_QuestItems;
    13.    
    14.     [ValueDropdown("WildlifeCharacters")]
    15.     public string m_WildlifeCharacters;
    16.  
    17.     public GlobalBuildings m_GlobalBuildings;
    18.  
    19.     public SpawnFaction m_Faction;
    20.     [HideInInspector] public static Transform Character;
    21.  
    22.     private string[] MobCharacters = new string[]{
    23.         "None", // Do not remove
    24.         "Raptor",
    25.         "Marine Ginger",
    26.         "Marine Samuel"
    27.     };
    28.     private string[] QuestCharacters = new string[]{
    29.         "None", // Do not remove
    30.         "Captain Skywalker",
    31.         "Captain Skywalkers Son",
    32.         "Joe Cunningham",
    33.         "Robert Tomson",
    34.         "Ted Macrig"
    35.     };
    36.     private string[] QuestItems = new string[]{
    37.         "None", // Do not remove
    38.         "Relic",
    39.         "Giant Relic"
    40.     };
    41.     private string[] WildlifeCharacters = new string[]{
    42.         "None", // Do not remove
    43.         "Empty"
    44.     };
    45.  
    46.  
     
  26. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    @Shadowing, instead of loading files by storing their name locally as a string, the reference to the asset file would be a public variable (or array) whose type is the same as your ScriptableObject type. Odin (which I also have here) is very capable of dealing with this.

    Your data object:

    Code (csharp):
    1.  
    2. public class SpawnableCreature : ScriptableObject {
    3.    public int creatureLevel = 1;
    4.    public string creatureName = "";
    5.    // and so on....whatever data you want
    6. }
    7.  
    And the MapLocation object that refers to the spawn objects:

    Code (csharp):
    1.  
    2. public class MapLocation : MonoBehaviour {
    3.    public string locationName;
    4.    public SpawnableCreature[] creatureOptions;
    5.    // and the rest of your data and methods
    6. }
    7.  
    Even without Odin, the Unity editor will give you a nice expandable array to drag and drop your asset files. The reference to each file is then stored by an internal GUID (a hashed value), which means it will stay valid even if you move those asset files to a different folder within the project. Adding Odin gives you all kinds of wonderful options for customized display and validation of these references.

    None of what we're discussing is impacted by Magic Markers, though -- basically, the markers behave like any other component (MonoBehaviour subclass). They function if their GameObject is active and the MagicMarker component itself is enabled, and are hidden if either of those conditions is not met. The influence of the GameObject's active or inactive state is enforced by Unity itself, so that is not something I can change.
     
  27. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I appreciate all the help man.
    I wasn't able to get this scriptableObject thing to work.
    I created two files

    so you saying the variables in the ScriptableObject should show up in the creatureOptions list in the inspector?
    That still doesn't solve the issue with having different files for each scene though. Cause I still have to use a Unique Class type with that way as well.
    The idea is to have different spawn lists for each Scene
    Also keep in mind I don't need it to store any other data but just the name of the mob. All character data is stored in my database on my server.


    Code (csharp):
    1.  
    2. using UnityEngine;
    3. public class NewAssetFile : ScriptableObject {
    4.    public string creatureLevel = "Item 1";
    5.    public string creatureName = "Item 2";
    6. }
    7.  
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. public class NewList : MonoBehaviour {
    4.    public NewAssetFile[] creatureOptions;
    5. }
    6.  
     
  28. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I came up with another option that I forgot about. I could use SendMessage to start my spawn. That toggle idea probably more efficient though lol. Since it doesn't get ran often probably alright.

    I just bought Magic Markers. I read more about it too. Looks pretty amazing.
     
    Last edited: Jan 21, 2018
  29. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Thanks! Please continue to post questions here in the forum. I do monitor this thread frequently.
     
  30. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    We're drifting a little off-topic for Magic Markers, but since MM itself uses ScriptableObjects, I think it's worth explaining them in the forum. :)

    I went into one of my "scratch" projects and created (and tested) some sample code for you. There are two classes.

    This class holds the data:

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. [CreateAssetMenu(menuName="Test Scriptable Object Data", order=900)]
    6. public class TestScriptableObjectData : ScriptableObject {
    7.    
    8.     public string name;
    9.     public int databaseKey;
    10. }
    11.  
    [/QUOTE]

    This class uses zero or more of the data objects:

    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. public class TestGameObjectWithDataItems : MonoBehaviour {
    6.    
    7.     public TestScriptableObjectData[] dataItemsList;
    8.     // Use this for initialization
    9.     void Start () {
    10.        
    11.     }
    12.    
    13.     // Update is called once per frame
    14.     void Update () {
    15.        
    16.     }
    17. }
    18.  
    As with the marker type assets in Magic Markers, you have to remember to create some of the data asset files so you can add them to the array in the GameObject.

    Here are the steps I followed to make this work:
    1. Compile the two C# scripts above.
    2. From the Project view, right-click on any folder (including the top one) where you want to store these data assets. Choose "Create" and then "Test Scriptable Object Data" from the menu and then name the resulting file.
    3. Click on the asset file you just created, and populate its name and database key fields as you wish. (I am assuming you have an index field in your database that is the unique row ID for each creature type...you can substitute whatever fields you wish in the data file later, since this was just for illustration of how to make the data files.)
    4. Repeat steps 2 and 3 for each creature type you want to define.
    5. Create an empty GameObject in your scene that will represent your map location.
    6. Add the TestGameObjectWithDataItems component (just once) to the map location GameObject. Since this thread is about Magic Markers, I shamelessly plugged MM by adding the diamond marker (which is meant for map markers) as well. This sort of situation is exactly what that diamond marker shape is meant to do. :)
    7. Drag and drop one or more of the ScriptableObject data assets onto the name of the array (Data Items List) in the GameObject inspector.
    In this arrangement, the asset files are not saved as part of the GameObject, but rather a reference to each of the asset files you choose is saved with the GameObject in your scene. You can use the GameObject to make prefabs and reuse them within the scene or on different scenes. Not only can you choose different lists of creatures (represented by the ScriptableObjects in different scenes, but you can also make different spawn points within the same scene that have different lists of creature assets. It's all up to you.

    Unity doesn't store the file paths in the dataitemsList[] array, but rather the GUID hash of each asset. So you can later decide to move all your creature-reference assets to a different folder in your Project view, and Unity will not lose the links from your GameObjects. If you update one of the asset files using its own inspector, this change will propagate to *all* GameObjects in *all* scenes which use that particular creature asset file.

    The one drawback, as you might have noticed, is that you can't directly edit the contents of the ScriptableObject assets within the GameObject inspector. You see their filenames but not the internals. If you want to be able to edit them directly, there are two ways to do this:
    1. I'm pretty sure (but don't take this as holy writ...) that Odin will do that for you easily.
    2. You can create a custom editor class to do this. Doing so is not trivial, but you have just purchased Magic Markers, which has a fairly complex version of just such a custom editor inside. You can look at the source code for Magic Markers to see how I did it, then make similar code for your own custom object. :) I can't write that code for you, as that's outside the scope of Magic Markers as an asset, but you can learn the design pattern from my code and then create your own.
    I am attaching some screen shots of the example code in action in a test scene. (Please ignore the other objects -- this was a scene I was using to test some other things not related to Magic Markers.)

    ScriptableObject-DataInspector.JPG ScriptableObject-DataItems.JPG ScriptableObject-InScene.JPG ScriptableObject-InspectorFilled.JPG ScriptableObject-Menu.JPG
     
  31. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Sorry for the troubles man.
    Actually I decided to just use prefabs so now my Spawn scripts are no longer unique.
    Cause really the drop down list is just adding an additional step for me every time I create a new object type to spawn.
    I figure i should remove as little steps as possible.

    I figured out how to auto add MagicMarker component when I add my spawn component and to collapse it as well.
    I couldn't find anything your docs that shows how to change the Magic marker type by script.

    I tried something like this below but it didn't give me a list of types to choose from.
    Code (csharp):
    1.  
    2. magicMarker.markerType = MarkerType. ---------
    3.  
     
  32. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Remember that marker types are asset files (they are actually ScriptableObjects stored in assets), so what you are essentially asking is for your source code editor's Intellisense to provide a list of matching files. Intellisense is great, but it can't do that for Magic Markers, or any other file type.

    What's the use-case of needing to change the marker type at runtime? If you just need to change its color to indicate active or inactive, then instead of having two different types, just use the local color override for the primary or secondary (or both) color. Take a look at the example in MagicMarkers.Demo.DestinationMarker class; it does a local color override and then resets to the default global color (from the marker type) later.

    If you really need to change marker types at runtime, the two ways I'd do that are one of the following:
    1. In your own class, as part of the prefab, have your own public Marker Type fields (two of them) that you can set from the inspector and store with the prefab. Make one of these your default type, and the other a temporary override for whatever it is you want to indicate. Then your code can do something like
      Code (csharp):
      1. magicMarker.markerType = myOverrideMarker;
      to temporarily override, and so on.
    2. Attach two Magic Marker components to your prefab, and enable only one of them at a time. This makes it so you're just setting and clearing a couple of booleans and will be very fast at runtime.
    Remember that Magic Markers have no GC allocations at runtime unless you modify the marker mesh, so if you actually swap the type at runtime, you'll take a temporary performance hit during the frame when you make the change. If you use my option #2 and just have two markers, you avoid that performance hit. Changing the marker's color but not altering its shape also will not cause the performance hit. The issue of changing geometry is that my code has to recalculate the procedural mesh if you do so, and I can't avoid a little GC allocation in that process. (But it's only for one frame, even so.)
     
  33. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Its so that when i create a new Spawn I don't have to select the magic marker type.
    Thats one entire step i'll be eliminating. Guess i could just use the same Mesh for everything and change its color. ehh.
    Its mostly so i know something is there honestly. So I don't place something on top of a spawn.

    Edit: idk im thinking now just using the same mesh and color for everything. Cause I just realize I have a drop down list that I select for spawn type such as questNPC, building etc...
    I might as well just remove that type and set the type on the magic marker component lol.
    But really If i just use the same color and same mesh for everything then thats one entire step I can eliminate. So i'm barely using the magic marker asset now lol.

    I could higher a kid in the future to go back over my scenes and set all the magic markers too I guess to make it look nice. I do have my spawns in different lists in my scene to so I could change a ton at once.
     
    Last edited: Jan 24, 2018
  34. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    The marker type field can be populated in your prefab, then each instance of the prefab will carry the selected type with it. You can make different prefabs with the different types of marker you want to use. This is the way you would do it with other asset file parameters, for instance meshes, materials, sound clips, etc.
     
  35. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    i don't understand how the colors work. If i change it to anything other than black the material disappears.
     
  36. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    I can tell you why that happens, but I also will respectfully suggest watching the tutorial videos, because this is documented (and intentional) behavior. :)

    The local color settings override the colors from the marker type, as you know. There has to be a special value that tells the Magic Marker scripts that the local color is not in use. This is done by looking at the alpha channel on the local color. If it is zero (clear), then the local color is ignored and the marker type color prevails.

    This works because it would not make sense to have an invisible marker.

    Try changing the local color of a marker, but make sure you also set the alpha channel to a nonzero value.

    Here is the specific part of the tutorial video that covers this topic:


    Hope that helps!
     
  37. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Thanks man. Also i noticed if you collapse Magic marker component it hides all magic marker meshes.
     
  38. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Ironically, I never noticed that. I'll bet Unity doesn't call the OnGUI() or OnDrawGizmos() methods for collapsed components. Interesting.
     
  39. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Also i found weird that if you collapse one magic marker component they all collapse in the scene.
    I just upgraded to 2017.3 and I don't think it did this in 5.6. Pretty sure I would of noticed that lol. But maybe not.
     
  40. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    I'll look into this. It is very likely outside my control. Any component can only "hook" the calls that the Unity engine (or editor) makes to that component; if they don't call my method, my method is powerless to actually do the draw. But you may be right that it's a Unity version-specific behavior. Even if I can't change it, I will see that it's added to the documentation.
     
  41. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    I've done some testing on this. First, it's true that this is a Unity editor thing. Unity doesn't call the OnDrawGizmos() method when the component is collapsed, and it's Unity that decides to collapse the same component on all objects of that type.

    I made an extremely simple (basically "hello world" with some Debug.Log() calls) GameObject to test the behavior, and tried this in Unity 5.4.6, which is the very earliest version of Unity that Magic Markers officially supports.

    Applying my trivial script to multiple objects in the scene, if I collapse it on one, it collapses on all of them, just as you observed. My theory is that Unity's programmers assumed that if you're moving around the scene looking at specific properties, you're probably looking at the same component and property as you move from object to object -- but I'm just guessing. In any case, the behavior is exactly as you observed, and it's completely outside my control as far as I can tell.

    The other test was to see when the Update() and OnDrawGizmos() methods are called. Even in 5.4.6, OnDrawGizmos() is not called at all if the component is collapsed in the editor, and the previous paragraph explains why this is happening for all the Magic Markers in the scene.

    Whether or not Update() is called in the editor is a more complicated issue. Without boring you with the details, let's just say I am testing this (and have received some useful suggestions from someone in the community...thanks!). I'll see what I can do to improve this behavior.
     
  42. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Actually, before I spend a lot of time on this issue, let me ask: Is the fact that the markers disappear when the component is collapsed a "problem" or a "useful feature" to let you hide them? I'll keep looking, but I don't want to "fix" something away and then find out users actually liked it the original way. :)
     
  43. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I wouldn't waste to much time on it. In a perfect world be nice to hide and unhide up in the menu somewhere.
    Wouldn't say its a some massive problem. I have the magic marker component set to auto hide right now but I can just remove that. It might mess with people though. They may load their project one time and realize no markers are not shown lol. so that may halt them for a couple of mins.

    Thanks for talking to me about the spawn stuff. It lead me into a direction to creating a much better design. I'm using the entire asset now of Magic Marker. Its really an amazing asset. Really love it. Will give you a review soon. Idk what I would do with out it.


     
  44. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    Thanks for posting the screenshot! It's cool to see my asset in use in the wild. :)
     
  45. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    For information: I have begun testing Magic Markers on the Unity 2018.1 beta. In the "default" render pipeline, the 2017.3 version of Magic Markers seems to Just Work so far. (I literally just began testing an hour ago, so consider this a "preliminary" result not a formal statement of support.)

    I am waiting for the Scriptable Render Pipeline code to download from Github, and then I will test there. Indications from the Asset Publishers channel from the Unity team are that I will have to rework some code and materials, but we'll see. I will post an update here as soon as I have had time to assess the situation and estimate how long it will take.

    In the meantime, please note that beta versions of Unity are not officially supported in Magic Markers. I am pretesting, and you're welcome to do the same and report results here to help in the process, but I can't promise perfect results in a beta Unity version.
     
  46. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I noticed another issue. Actually noticed the first day of having the asset. Now that I've been using its a little bit annoying.
    When you select the mesh type using the inspector selector. When you select a type it changes the type in the scene which is good. But if you change the type again with out closing out the inspector selector it won't it. It will stay at the first one you selected.

    Let me know if that makes sense.
    Steps
    select a new mesh type on the Magic Marker component
    then with out closing out that selector box select another one and you will notice that it didn't change to the last one selected.
     
  47. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Also why are there two boxes when selecting cube?
    can't figure that out?


     
  48. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    I will test for this. I am working on a new version right now, and was coding last night in fact.

    This may not be something I can fix. If Unity's editor doesn't send me an OnDrawGizmos() or Update() event, then my code has no way of knowing about the change. But I will definitely investigate this problem and fix it if I can. Thanks for reporting the issue!
     
  49. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    I know what is causing this. Take a look at the settings for the marker type (either my default Cube or the asset file you have created for your own custom type). If you have the Highlight Mode set to "Edge Lines", and if the GameObject to which the marker is attached has a scale other than 1.0, you will see this effect.

    The bad news is this is a cosmetic bug in Magic Markers. The good news is, I have already fixed it in the new version which I will be releasing in a few days.

    As a workaround, you can use the Wireframe highlighting mode if your graphics drivers can support Shader Model 4.0 or later.

    I apologize for the bug. I'm finishing up the new release, and this bug is corrected in the new version.
     
  50. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Sorry for posting so many questions lol. My project is pretty late in development. So Im using it pretty heavily.
    When using the Alert mesh. I notice there is no scale for it? Wondering why you did that?
    I notice there is none for cube as well.
    I guess you assume you would want the editor to show the entire area its effecting.
    I have some large triggers that i was wanting to use the alert on that I didn't want it to take up the entire parent size. Since the parent is scaled upwards.

    another way to explain it lol.
    I have a magic marker inside a magic marker. The parent i have scaled up huge and i don't want the child magic marker matching its scale. I think you should have a boolean that overrides parent scaling and then shows a scale slider.