Git Product home page Git Product logo

3d-wiki's People

Contributors

dependabot[bot] avatar mhulse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

3d-wiki's Issues

Basic Unity tips found here

Quick copy/paste dump:

Move code out of loops when possible

Loops are a common place for inefficiencies to occur, especially when they are nested. If a loop runs frequently on many GameObjects, efficiency will decrease.



Consider whether code must run every frame

The Update() function runs every frame. Use Update() for code that must  change often. Otherwise, move code out of Update() so that it runs only when it needs to.

 

Run code every [x] frames

For code not trigged by an event, you can choose to run it every [x] frames. The following example runs ExampleFunction every 3 frames.



private int interval = 3;

 

void Update()

{

    if (Time.frameCount % interval == 0)

    {

        ExampleFunction();

    }

}

 

Reduce use of GetComponent()

Storing and reusing function results is efficient. This technique is known as caching.

GetComponent() is a good opportunity to cache and increase optimization.

The following code calls GetComponent() only once, as the result of the function is cached. The cached result can be reused in Update() without any further calls to GetComponent() .



private ExampleComponent componentName;

 

void Start()

{

    componentName = GetComponent<ExampleComponent>();

}

 

void Update()

{

    ExampleFunction(componentName);

}

 

Use object pooling

Object pooling temporarily deactivates, recycles, and reactivates objects as needed. This is more efficient than instantiating and destroying objects.

https://www.udemy.com/masterunityandblender/learn/v4/announcements?ids=2061096

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.