Convert Figma logo to code with AI

Unity-Technologies logoAnimation-Instancing

This technique is designed to instance Characters(SkinnedMeshRender).

1,641
298
1,641
61

Top Related Projects

1,081

Skinned mesh sampling with VFX Graph

Unity Graphics - Including Scriptable Render Pipeline

Central repository for tools, tutorials, resources, and documentation for robotics simulation in Unity.

Quick Overview

The Unity-Technologies/Animation-Instancing repository is a Unity package that provides a set of tools and utilities for optimizing the performance of animated objects in Unity. It allows developers to batch and instance animated objects, reducing the overall draw call count and improving rendering performance.

Pros

  • Improved Performance: The animation instancing feature can significantly reduce the number of draw calls required to render animated objects, leading to improved performance, especially in scenes with a large number of animated elements.
  • Flexible Integration: The package can be easily integrated into existing Unity projects, allowing developers to take advantage of the performance benefits without major changes to their codebase.
  • Compatibility: The animation instancing feature is compatible with a wide range of Unity versions, making it accessible to a broad range of developers.
  • Active Development: The project is actively maintained by the Unity Technologies team, ensuring regular updates and bug fixes.

Cons

  • Limited Documentation: The project's documentation could be more comprehensive, making it challenging for new users to get started and understand the full capabilities of the package.
  • Specific Use Cases: The animation instancing feature may not be suitable for all types of animated content, as it works best with simple, repetitive animations.
  • Potential Complexity: Integrating the animation instancing feature into a complex project may require additional effort and optimization to ensure seamless integration.
  • Dependency on Unity: As this is a Unity-specific package, it is not applicable to projects that do not use the Unity engine.

Code Examples

N/A (This is not a code library)

Getting Started

N/A (This is not a code library)

Competitor Comparisons

1,081

Skinned mesh sampling with VFX Graph

Pros of Smrvfx

  • Smrvfx provides a more comprehensive set of VFX tools, including support for particle systems, trails, and other advanced effects.
  • The project is actively maintained and regularly updated, with a responsive developer community.
  • Smrvfx integrates well with other Unity packages and tools, making it a versatile choice for VFX development.

Cons of Smrvfx

  • Smrvfx may have a steeper learning curve compared to Animation Instancing, as it offers a wider range of features and functionality.
  • The project's documentation and tutorials may not be as extensive as those available for Animation Instancing.

Code Comparison

Animation Instancing:

public class AnimationInstancingExample : MonoBehaviour
{
    public Animator animator;
    public int instanceCount = 100;

    void Start()
    {
        for (int i = 0; i < instanceCount; i++)
        {
            GameObject instance = Instantiate(gameObject, transform.position, transform.rotation);
            instance.GetComponent<Animator>().SetTrigger("Trigger");
        }
    }
}

Smrvfx:

public class ParticleSystemExample : MonoBehaviour
{
    public ParticleSystem particleSystem;
    public int instanceCount = 100;

    void Start()
    {
        for (int i = 0; i < instanceCount; i++)
        {
            ParticleSystem instance = Instantiate(particleSystem, transform.position, transform.rotation);
            instance.Play();
        }
    }
}

Unity Graphics - Including Scriptable Render Pipeline

Pros of Graphics

  • Focuses on advanced graphics features and rendering techniques, such as ray tracing and global illumination.
  • Provides a more comprehensive and flexible graphics pipeline for Unity developers.
  • Includes experimental features and cutting-edge graphics technologies.

Cons of Graphics

  • May have a steeper learning curve for developers not familiar with advanced graphics programming.
  • Some features may not be as well-documented or supported as the core Unity engine.
  • Potential performance impact for less powerful hardware.

Code Comparison

Graphics:

var result = RayTracingManager.RayTrace(
    ref rayDesc,
    ref hitInfo,
    ref rayPayload,
    ref rayIndex,
    ref pixelCoord,
    ref frameIndex,
    ref randomSeed,
    ref sampleIndex,
    ref rayContribution,
    ref rayThroughput,
    ref rayDepth,
    ref rayFlags,
    ref rayTime,
    ref rayDirection,
    ref rayOrigin,
    ref rayLength,
    ref rayHitT,
    ref rayHitDistance,
    ref rayHitNormal,
    ref rayHitUV,
    ref rayHitTriangleIndex,
    ref rayHitInstanceID,
    ref rayHitPrimitiveIndex,
    ref rayHitMaterialIndex,
    ref rayHitObjectToWorld,
    ref rayHitWorldToObject
);

Animation-Instancing:

var animationClip = new AnimationClip
{
    name = "MyAnimation",
    frameRate = 30,
    wrapMode = WrapMode.Loop,
    events = new[]
    {
        new AnimationEvent
        {
            time = 0.5f,
            functionName = "OnAnimationEvent"
        }
    }
};

Pros of EntityComponentSystemSamples

  • Provides a comprehensive set of examples and samples for the Entity Component System (ECS) in Unity, which is a powerful and efficient architecture for building games and applications.
  • Includes a wide range of sample projects, from simple demos to more complex use cases, showcasing the versatility and capabilities of ECS.
  • Offers detailed documentation and explanations, making it easier for developers to understand and adopt the ECS approach.

Cons of EntityComponentSystemSamples

  • The repository is primarily focused on ECS, which may not be suitable for all types of projects or developers who prefer the traditional GameObject-based approach.
  • The samples may not always be up-to-date with the latest Unity versions, requiring some effort to ensure compatibility.
  • The learning curve for ECS can be steeper compared to the traditional GameObject-based approach, which may be a barrier for some developers.

Code Comparison

Here's a brief code comparison between the two repositories:

Animation-Instancing

public class AnimationInstancingExample : MonoBehaviour
{
    public Animator animator;
    public int instanceCount = 100;

    void Start()
    {
        for (int i = 0; i < instanceCount; i++)
        {
            GameObject instance = Instantiate(gameObject, transform.position, transform.rotation);
            instance.GetComponent<Animator>().SetTrigger("Idle");
        }
    }
}

EntityComponentSystemSamples

public class MoveSystem : ComponentSystem
{
    protected override void OnUpdate()
    {
        Entities.ForEach((ref Translation translation, in Rotation rotation, in MoveSpeed moveSpeed) =>
        {
            translation.Value += rotation.Value.Forward * moveSpeed.Value * Time.DeltaTime;
        });
    }
}

The key difference is that the Animation-Instancing example uses the traditional GameObject-based approach with Animator components, while the EntityComponentSystemSamples example demonstrates the use of the ECS architecture, which separates data and logic into distinct components and systems.

Central repository for tools, tutorials, resources, and documentation for robotics simulation in Unity.

Pros of Unity-Robotics-Hub

  • Provides a comprehensive set of tools and resources for robotics development, including ROS integration, simulation environments, and sample projects.
  • Offers a collaborative platform for the robotics community to share knowledge and contribute to the project.
  • Includes a wide range of tutorials and documentation to help developers get started with robotics development in Unity.

Cons of Unity-Robotics-Hub

  • May have a steeper learning curve for developers who are not familiar with robotics or ROS.
  • The project may not be as actively maintained or updated as some other Unity-related repositories.
  • The scope of the project may be more specialized and less applicable to general Unity development tasks.

Code Comparison

Unity-Robotics-Hub:

public class RobotController : MonoBehaviour
{
    public float moveSpeed = 1.0f;
    public float rotationSpeed = 45.0f;

    private void Update()
    {
        float horizontal = Input.GetAxis("Horizontal");
        float vertical = Input.GetAxis("Vertical");

        transform.Translate(Vector3.forward * vertical * moveSpeed * Time.deltaTime);
        transform.Rotate(Vector3.up * horizontal * rotationSpeed * Time.deltaTime);
    }
}

Unity-Animation-Instancing:

public class AnimationInstanceManager : MonoBehaviour
{
    public GameObject prefab;
    public int instanceCount = 100;

    private void Start()
    {
        for (int i = 0; i < instanceCount; i++)
        {
            Instantiate(prefab, transform.position + new Vector3(i * 2, 0, 0), Quaternion.identity);
        }
    }
}

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

As developers, we’re always aware of performance, both in terms of CPU and GPU. Maintaining good performance gets more challenging as scenes get larger and more complex, especially as we add more and more characters. Me and my colleague in Shanghai come across this problem often when helping customers, so we decided to dedicate a few weeks to a project aimed to improve performance when instancing characters. We call the resulting technique Animation Instancing.

It needs at least Unity5.4.

Features:

  • Instancing SkinnedMeshRenderer
  • root motion
  • attachments
  • LOD
  • Support mobile platform
  • Culling

Note: Before running the example, you should select menu Custom Editor -> AssetBundle -> BuildAssetBundle to build asset bundle.

Attachments:

There's a attachment scene. It shows how to use the attachments. How to setup the object which hold the attachment?

  • Open the generator menu -> AnimationInstancing -> Animation Generator
  • Enable the attachment checkbox
  • Selece the fbx which refrenced by the prefab
  • Enable the skeleton's name to generate
  • Press the Generate button.