Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by james82 · Jul 12, 2017 at 06:00 AM · c#api

How to use unity scripting api?

How we use unity scripting API when programing?is API like standard library ? How API work? example how to use it?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by tanoshimi · Jul 12, 2017 at 06:17 AM

The API contains all the methods to achieve anything through code in Unity. It essentially is Unity - certainly from a programmer's perspective. https://unity3d.com/learn/tutorials

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Jul 12, 2017 at 11:27 AM 1
Share

If @SohailBukhari answer is wrong, than this is wrong as well -.-. The Unity API only coveres methods / classes / types defined in the UnityEngine.dll. (and lately all the extension dlls like UI, networking, ...). Anything else (mscorlib.dl, System.dll, ...) is part of the mono framework which can also be used but is not part of the Unity API.

So if you're not too nitpicky both answers are correct with $$anonymous$$or mistakes / ambiguities so i give an upvote to both ^^.

avatar image
0

Answer by SohailBukhari · Jul 12, 2017 at 06:26 AM

Application program interface (API) is a set of routines, protocols, and tools for building software applications. An API specifies how software components should interact. Additionally, APIs are used when programming graphical user interface (GUI) components. A good API makes it easier to develop a program by providing all the building blocks. A programmer then puts the blocks together.

Best explanation of API https://en.wikipedia.org/wiki/Application_programming_interface

MonoBehaviour is the API, MonoBehaviour is the base class from which every Unity script derives.

Edited: (thanks to @Hellium)

When you use C# "as unity script to interact with unity gameobjects", then you must explicitly derive from MonoBehaviour.

Yes you do not need all of c# classes to be drived from MonoBehaviour (When you do not need to interact with GameObjects) When you use UnityScript (a type of JavaScript), you do not have to explicitly derive from MonoBehaviour.

Note: There is a checkbox for disabling MonoBehaviour on the Unity Editor. It disables functions when unticked. If none of these functions are present in the script, the Editor does not display the checkbox. The functions are:

  • Awake()

  • Start()

  • Update()

  • FixedUpdate()

  • LateUpdate()

  • OnGUI()

  • OnDisable()

  • OnEnabled()

Basically we designed API in the way that a programmer use its public methods in his script and all private members are hidden from the user, we call only API and get our desired result without doing anything.

Lets take an example we want to use String API Represents text as a series of Unicode characters.

Unity uses the .Net System.String class for strings.

Note: In c# string is an alias for System.String. This means that you can use either string or String in your code (if you have added using System to the top of your script.) Every component has its own API in the unity engine.

Comment
Add comment · Show 17 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image james82 · Jul 12, 2017 at 08:53 AM 0
Share

thankyou. really detail, helpful.

avatar image Hellium · Jul 12, 2017 at 09:55 AM 2
Share

You are wrong on many levels :

  • $$anonymous$$onoBehaviour does not represent the Unity API

  • You don't have to make your classes derive from $$anonymous$$onoBehaviour when using C#. You can have pure C# classes or make your class extend a Unity component or the ScriptableObject class or Editor class or many, many others

  • Unity does not use .Net, but its open source version : $$anonymous$$ono

  • And a script with the Awake method only won't have a checkbox in the Inspector. It will be called once the gameobject is enabled

avatar image Bunny83 Hellium · Jul 12, 2017 at 11:20 AM 1
Share

I wouldn't be that harsh as most information provided is not wrong, just incomplete. "The Unity API" does of course cover all classes that Unity provides to you (everything defined inside the UnityEngine.dll). However $$anonymous$$onoBehaviour is the main link between Unity and a script. Note that he said script, not class. A script file in Unity is most the time used as Component. Any other use of classes are not related to the Unity API at all since it's just plain C#.

Yes Awake doesn't belong to that list of methods, however that is not his fault as this is the list copied from the docs. So it's just another case where the documentation has it wrong -.-

While technically it's right that Unity doesn't use .NET (at least on most platforms), $$anonymous$$ono is ment to be a 100% compatible replacement (which it probably never reach). The mono project site even states:

$$anonymous$$ono is an open source implementation of $$anonymous$$icrosoft's .NET Framework

this technically makes mono being an implementation of the .NET framework.

As i said most he said is not plain wrong, just incomplete or with a limited view.

avatar image SohailBukhari Bunny83 · Jul 12, 2017 at 11:42 AM 0
Share

Thanks for your precious comment.

avatar image SohailBukhari Hellium · Jul 12, 2017 at 12:19 PM 0
Share

"There is a checkbox for disabling $$anonymous$$onoBehaviour on the Unity Editor. It disables functions when unticked. If none of these functions are present in the script, the Editor does not display the checkbox". i mean our $$anonymous$$onoBehaviour won't have a checkbox next to it in the inspector if it doesn't have any of the per-frame methods, like Update, FixedUpdate, OnGUI, etc.

avatar image samiciit Hellium · Jul 12, 2017 at 02:19 PM 1
Share

@Hellium help us to learn.

  1. $$anonymous$$onoBehaviour does not represent the Unity API. So unity tells it wrong as scripting API?

  2. You don't have to make your classes derive from $$anonymous$$onoBehaviour? Who asked you to do that? $$anonymous$$onoBehaviour is the base class from which every Unity script derives (its not about all of your classes when writing any script in unity)

  3. Why you want to prove it wrong that Unity uses System.String of .Net framework. It actually does via $$anonymous$$ono (As $$anonymous$$ono is an open source implementation of $$anonymous$$icrosoft's .NET Framework)

All three points are wrong. . We are supposed to be supportive here not lawyer to prove others wrong by manipulations. I am sorry for this but I have been unable to put my request with better wording.

avatar image Hellium samiciit · Jul 12, 2017 at 02:47 PM 1
Share
  1. As indicated by @Bunny83, the Unity API is all the classes, the functions, interfaces, .... defined in UnityEngine.dll and UnityEditor.dll. The $$anonymous$$onoBehaviour class is the base class of your custom class you want to make as a component to attach to a gameobject. But a "Unity script" (which means everything and nothing) can derive from Editor for example.

  2. SohailBukhari indicated that "When you use C#, you must explicitly derive from $$anonymous$$onoBehaviour.", which is false (see point #1)

I am simply fixing what's wrong in SohailBukhari's answer. I apologize if it has been interpreted as too rudely.

Show more comments
Show more comments
avatar image tanoshimi · Jul 12, 2017 at 11:54 AM 0
Share

Are you a bot? This answer seems like some arbitrarily copy-pasted paragraphs from Wikipedia, and the Unity script reference, and here, and really doesn't make much sense.

Aside from the issues @Hellium has already mentioned: "$$anonymous$$onoBehaviour is the API"... "we want to use String API"... ? So you want to use the String $$anonymous$$onobehviour? This really makes no sense. I don't see how your mention of GUI components is at all relevant to the question. Private members are not "hidden from the user" - they are inaccessible to other classes, and there is no OnEnabled() function - it's OnEnable().

avatar image SohailBukhari tanoshimi · Jul 12, 2017 at 12:40 PM 0
Share

Lets take an example we want to use String API Represents text as a series of Unicode characters.`String API example means`

  example = String.trim(example);
 example = String.replace(example, 'a', 'b');


basically String.trim(example) is method of String API class which we use to trim.

avatar image tanoshimi SohailBukhari · Jul 12, 2017 at 02:57 PM 0
Share

I think you understand correctly, but your ter$$anonymous$$ology is wrong: Trim and Replace (note capital letters) are methods of the String class. There is no "String API Class".

Show more comments
avatar image james82 · Jul 12, 2017 at 02:37 PM 0
Share

hello. normally what line always appear unity api word?is it method signature line? any other line?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

353 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Making a bubble level (not a game but work tool) 1 Answer

get the duration of the curently playing clip of the timeline? 1 Answer

Detect if build target is installed 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges