Code Monkey home page Code Monkey logo

Comments (8)

chrisxue815 avatar chrisxue815 commented on July 18, 2024

Start is called in Awake below

from cs7038.

anokta avatar anokta commented on July 18, 2024

so that's always the case, then?

from cs7038.

chrisxue815 avatar chrisxue815 commented on July 18, 2024

I added the Awake method in c41461b, to make sure spriteRenderer is initialized before using LaserEmitter.Direction.

from cs7038.

anokta avatar anokta commented on July 18, 2024

THAT LOOKS WRONG. :)

from cs7038.

chrisxue815 avatar chrisxue815 commented on July 18, 2024

I will try removing the Awake and see if there's another solution.

from cs7038.

anokta avatar anokta commented on July 18, 2024

no worries, i've already changed it now, will commit it in a minute.

from cs7038.

chrisxue815 avatar chrisxue815 commented on July 18, 2024

http://goo.gl/sWzunQ this thread may help.

from cs7038.

Zoodinger avatar Zoodinger commented on July 18, 2024

This is really simple:

  • Use Awake for all initialization logic that does not depend on other objects.
  • Use Start for all initialization logic that depends on other objects.

Just using either Start or Awake is fine in most cases, but in some cases we do need to be more specific.However, calling ANY Unity method manually is a bad idea. The very reason why these methods are private by default is to prevent other scripts from accessing them.

But here is one detail that might be important someday (it was to me when I wrote GroupManager): Awake will always be called, but Start might not if the script is inactive after the Awake method (by disabling it in the Inspector or by calling this.enabled = false in the Awake method), in which case it will be called when the script is activated.

from cs7038.

Related Issues (20)

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.