Thursday, March 15, 2012

Unity Tools

My Object Placement Tools for Unity got accepted to the Asset Store yesterday

5 comments:

  1. The scripts are Editor scripts, and cannot be used as components as far as I understand. How do I use this plug in, please? I'm not a coder - using playMaker.

    ReplyDelete
    Replies
    1. I'm sorry, I know this is a really late reply, but the scripts are for helping place objects in the scene not components. They are to help with the process of setting up scenes and make it less tedious. Align is meant to match transform properties: location, rotation, and scale to help line them up and such as well as swapping objects. Duplicate is meant to give you more options when creating copies of objects. Random Offset is intended to easily give objects' transforms some variation. Move to Surface is meant to move your selected objects to the next surface in the chosen direction. What were you wanting to do with them?

      Delete
    2. Hi i just bought your toolset, unfortunatly it did not care about prefabs. Means, if a selection was acutually a prefab instance, after duplication the duplicate was not.

      I rewrote the script a bit to support that, at least for direct prefabinstances (thus, if you duplicate a hierarchy and somewhere inside is a prfeabinstance, that want work).

      As you did not leave any email adress or supportpage in the assetstore, i can only show you the code here:

      Extrafunction to do the duplication:
      GameObject duplicateFrom(GameObject source, Transform dupTransform) {
      // is the Selection a Prefab Instance?
      GameObject go = null;
      GameObject prefab = PrefabUtility.GetPrefabParent( selObj[objNumber]) as GameObject;
      if (prefab != null) {
      // if it is, create an Instance of the prefab
      go = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
      go.transform.position = dupTransform.position;
      go.transform.rotation = dupTransform.rotation;
      } else {
      go = Instantiate(selObj[objNumber], dupTransform.position, dupTransform.rotation) as GameObject;
      }

      // reparent the copy
      go.transform.parent = dupTransform.parent;
      go.transform.localScale = dupTransform.localScale;
      return go;
      }


      called like:
      GameObject go = duplicateFrom(selObj[objNumber], dupTransform);

      So replace your old instantiate things with this function call. Works at least with your last two thingies.

      Delete
    3. You're right, I completely forgot about prefab instances. Thanks for bringing that up and for your helpful bit of code.

      Delete