Blog

Introducing String Manager

PLEASE NOTE THIS MANAGER ONLY WORKS FOR VERSIONS OF STRING PRIOR TO 2.0. A NEW VERSION WILL BE RELEASED AS TIME ALLOWS TO SUPPORT STRING 2.0 AND UP.

Attention: String Manager has recently been refactored with expanded functionality for even easier usage and has shaved off 178KB from your final build size. If you are using an older version please delete the previous version’s folder and install the new version available from the download link below.

I’ve finally decided to compile some of my tricks and techniques that I often integrate into one of String’s two managers into the end-all, be-all manager component for working with String. This new component should be added to your camera just as with either the CameraCentric or ContentCentric managers – or not if you want it to yell at you – and is a complete replacement for using them. In addition to allowing easier swapping between the two styles of tracking, this new manager also empowers you with some battle-tested techniques that will help you concentrate on content rather than augmented reality while pulling the most out of String’s features.

Usage is simple, first select a style which is identical to choosing between String’s out-of-the-box, bare-bones managers. After a style is set, String Manager will automatically adjust itself to offer parameters specific to each style. I don’t think documentation is required for the options and root objects section of the tool (if I’m wrong let me know) and live light color sampling is easily accessible with the usage of the new GetSampledColor() method allowing color retrieval by augmentation id (which directly corresponds to the element id in your Root Objects list) or by a string name for the augmentation. Please note usage of live color sampling with String is only available on device in Developer, Pro and Campaign licenses.

Please note String Manager has recently been ported over to a singleton pattern for super-simple, global access. If you are unfamiliar with how singletons work all you need to know is that if you want to access any of its methods just add a call to “Instance” after the name: StringManager.Instance.GetSampledColor(). In addition, I also added three events that you can subscribe to in order to respond to the acquiring and loss of markers: OnMarkerFound, OnMarkerLost and OnDisabled. If you are unfamiliar with events watch Prime 31’s great tutorial on this powerful feature.

Examples for applying sampled color light from String:

//Application of light color setting on a Directional Light by root object id:
void Update (){
	light.color = StringManager.Instance.GetSampledColor(0);
}
//Application of light color setting on a Directional Light by root object name:
void Update (){
	light.color = StringManager.Instance.GetSampledColor("MyAugmentedObject");
}
//Application of light color setting to a material's Main Color by root object id:
void Update (){
	renderer.material.SetColor("_Color", StringManager.Instance.GetSampledColor(0));
}

Post any problems you encounter and keep in mind you will eventually outgrow this manager. New challenges will always require custom managers so keep the template managers String provides so you can extend your own possibilities beyond this tool once your experience grows.

Download

 

25 Comments

  1. Mike Renwick
    July 14, 2011

    Nice one Mr B.

  2. July 20, 2011

    This is brilliant.
    It’s made setting up a String scene so much faster. In fact I’ve found all your String posts really helpful.
    Donation coming your way.
    Thanks Bob.

  3. Jenny
    August 1, 2011

    Hi, thank you for all your work! 🙂

    I’m trying to install this String Manager but the very moment i import the package unity reports me 4 errors…

    all the errors are related to the GUI….

    • August 2, 2011

      This error is most likely because you are not running the latest version of Unity. Can you make sure you are running at least version 3.4?

  4. Jenny
    August 2, 2011

    Hi Bob and thank you for answering! 🙂

    I’m use unity3.3.0 F4 i can;t use 3.4 because String have problem with it (EAGLView wrapped into an UIViewController)…i can’t risk…becuase i’m just abut to release my app in few weeks.

    I loved the idea of this String manager (first of all because i don’t know how to use the real light without it)…

    Anyway thank you! I will wait the Fix from String 😉

    • August 2, 2011

      I’ll post a fix for Unity versions before 3.4 in just a few so everyone can keep working until the next release from String.

  5. Jenny
    August 2, 2011

    Thank you so much!
    You’re work is great and we all appreciate it!

    • August 2, 2011

      Thank you. I just uploaded a fix. Please re-download and let me know if it works on Unity version 3.3

  6. Jenny
    August 2, 2011

    Thank you so much Bob! Now it works perfectly on Unity 3.3!
    …honestly all the pipeline now is really fast and cool thanks to your String Manager!

  7. Elecman
    August 6, 2011

    Is it possible to have multiple markers in view with the Content Centric mode? I only manage to draw content on each separate marker in Camera Centric mode. In Content Centric mode, the content of the first Root Object is drawn on whichever marker comes into view first…

    • August 6, 2011

      Content Centric turns the user into a cameraman allowing control of the camera in use. Therefore it’s only possible to have one marker controlling the camera at a time. If you need multiple markers go for Camera Centric or roll your own solution that would allow for multiple cameras if their own manager for a specific marker.

    • Elecman
      August 6, 2011

      Thanks, makes sense.
      Another question. How is the position data managed? With QCAR the marker which is detected first will get the position 0,0,0 in Unity. Every other marker detected next will be offset from that marker. How does this work with String?

    • August 6, 2011

      Actually, QCAR has 3 possible options for handling world center: USER, AUTO, and NONE. NONE is identical to String’s Camera Centric and USER and AUTO are very similar to String’s Content Centric except the tracked content dictates world center. Sting does not change world center at all and is actually much more straightforward with respect to positional information.

    • Elecman
      August 7, 2011

      So if QCAR AUTO mode is similar to String Content Centric mode, why can String only have one marker visible in Content Centric mode while QCAR can have multiple markers visible in AUTO mode?

    • August 7, 2011

      I said “similar” 🙂

  8. Elecman
    August 7, 2011

    Got it

  9. August 22, 2011

    Hi Rob, thank you for this String Manager!

    I’m trying to add the light sampler but i don’t have the minimum idea of where to start.

    Where do i have to add the code, for example this one?

    //Application of light color setting on a Directional Light by root object name:
    void Update (){
    light.color = StringManager.GetSampledColor(“MyAugmentedObject”);
    }

    Do i have to child the light? I noticed in this version there is no light option in the manager….i’m a bit confused..

    Thank you in advance!

    Alessandro.

    • August 22, 2011

      Simply add that Update method to a light in your scene to see how it works. If you have only 1 augmentation then use an id of 0 or use the same of the object you have in Root Objects.

    • August 22, 2011

      Great! Its working and i don’t know why i didn;t thing to put the script on the light…

      Thank you.

      Alessandro.

  10. Marjan
    August 29, 2011

    Hi, i don´t understand the question from Alessandro above. I thought your stringmanager is already doing this? At least i see something like this in the code.
    But the effect i am achieving doesn´t seem to be as good as in your video, now i am a bit uncertain.
    Do i need those extra update scripts on lights or not?

    Great Work by the way!

    • August 30, 2011

      Thanks! You’ll need the light color updates if you want your scene tinted to match the color in the room. Make sense?

  11. Marjan
    August 30, 2011

    Yeah, but your manager has already an “sample and apply real light toggle” and the script sets color to the lights array, when i toggle it on like this:

    //apply light color:
    sampledColors[markerInfo.imageID] = markerInfo.color;

    if (sampleRealLight) {
    lights[markerInfo.imageID].color = markerInfo.color;
    }

    Thats inside an update funtion. So where is the difference to having this in an extra script then?

    • August 30, 2011

      Yes, I’ve since updated the manager (same link) and removed that approach in favor of what’s mentioned in the blog post now. I had a few occasions where I needed to tint aspects of a shader and not a light to better composite and tint a scene and came to the realization that forcing that light array approach was too limiting.

  12. Elecman
    October 15, 2011

    I have made another cool String manager, although it is a bit different then the current one.

    Most Augmented Reality applications draw some 3d content on top of a marker or around a marker. With this method the marker must be in view at all times and camera movement is therefore restricted. A new method uses multiple markers and brings them into a single coordinate system. This enables you to point the camera anywhere, as long as there are enough markers scattered around.

    You can find it on the Unity3d forum:
    http://forum.unity3d.com/threads/108256-Unified-Coordinate-System-for-String-and-QCAR?p=716332#post716332