Query for Unity

Hey guys (and girls)!

I’ve been writing these small utility and extension methods over and over again with each new project, and now I’m done with that :slight_smile: UnityQuery aims to collect the most general, versatile and helpful of these code snippets for re-use. It is a small, lightweight C# library designed to increase productivity with Unity3D.

Features:

  • Hierarchy queries (e.g. GetChildren, GetDescendants, OnLayer, IsAncestor, GetRoot, …)
  • Hierarchy manipulation (e.g. DestroyChildren)
  • Component-wise vector swizzling (e.g. v.XZ)
  • Changing single vector or color components while preserving immutability
  • Picking (e.g. object at mouse position)
  • Collection extensions (e.g. ContainsAll, GetValueOrDefault, IsNullOrEmpty, SequenceToString)
  • Logs with timestamps and object names

Examples:

Here are a few examples of what comes with UnityQuery.

foreach (var descendant in this.gameObject.GetDescendants().OnLayer("UI"))
{
    // Selects all descendants (children, grandchildren, etc.) of a game object.
}
// Instantiates a prefab and parents it to this one.
// Resets position, rotation and scale and inherits the layer.
this.gameObject.AddChild(prefab);
// v = (2, 3, 4)
Vector3 v = new Vector3(2, 3, 4);

// w = (2, 3, 5)
Vector3 w = v.WithZ(5);

Check the PDF cheat sheet for a quick glance of other features.

The full source code is available at GitHub. If you’re missing any of your personal favorites, we’d love to see it - we are always open for contributions! Just post an answer in this thread, and we’ll consider adding it in the next release.

If you need any help or experience any issues, feel free to contact us immediately.

Please note this library is not officially related to Unity Technologies in any way.

1 Like

UnityQuery 1.0.1 is now available at the Asset Store and GitHub, updating to Unity 5.3! Thanks to all contributors for your continuing support!

If you need any help or experience any issues, feel free to contact us immediately.

Remember, we are always open for contributions! Just post an answer in this thread, and we’ll consider adding it in the next release.

how to call multiple animation on single object …but it divide in parts …like i have a cube which we make with 6 plane then attach it…after that when i click on one plane call one animation same as when i click second plane …two animation call… like that i want to call 6 animation…

Can we import a unity file such that if I have multiple games then for each game I got a different activity while importing to android studio,Is it possible that if I have multiple games and I want to merge those games in single file, such that if I import it to android studio then in android studio user gets multiple activity

can we integrate multiple unity projects in android studio