Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Ingen · Jul 11, 2012 at 09:26 PM · #pragma

what are #pragma?

seems stupid but...

I look around and oly found for c and c++

in unity, I see they in js someone could explain me #pragma strict #pragma implicit #pragma downcast

  1. what are?

  2. what they do?

  3. when do use?

  4. there is others pragma?

I found this in a sample project, are really needed?

 #pragma strict
 #pragma implicit
 #pragma downcast
 
 class FadeLight extends MonoBehaviour
 {
  public var delay : float;
  public var fadeTime : float;
  
  private var fadeSpeed : float;
  private var intensity : float;
  private var color : Color;
  new pre
  function Start()new pre
  {
  if(light == null)
  {
  Destroy(this);
  return;
  }
  new pre
  intensity = light.intensity;
  
  
  fadeTime = Mathf.Abs(fadeTime);
  
  if(fadeTime > 0.0)
  {
  fadeSpeed = intensity / fadeTime;
  }
  else
  {
  fadeSpeed = intensity;
  }
  //alpha = 1.0;
  }
  
  function Update()
  {
  if(delay > 0.0)
  {
  delay -= Time.deltaTime;
  }
  else if(intensity > 0.0)
  {
  intensity -= fadeSpeed * Time.deltaTime;
  light.intensity = intensity;
  }
  }
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by SarperS · Jul 11, 2012 at 09:47 PM

1 - Those are pragma directives.

2 - They define directives for the compiler, basically they change the way your compiler treats your code.

pragma strict - disables dynamic tyipng
pragma implicit - let's you declare types implicitly
pragma downcast - enables casting from supertypes to subtypes

3 - It's just a matter of personal preference.

4 - There are no other builtin pragma directives.

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 Ingen · Jul 11, 2012 at 10:09 PM 0
Share

thank you very much

why receive this error?

Assets/Scripts/CameraRayActivator.js(41,13): BCW0028: WARNING: Implicit downcast from 'UnityEngine.Object' to 'UnityEngine.GameObject'.

in

@$$anonymous$$enuItem("$$anonymous$$y Top Level $$anonymous$$enu/Some Component") static function AddSomeComponent() { for(var o : GameObject in Selection.objects) { o.AddComponent(SomeComponent); } }

when not use pragma strict, otherwise this work very good (thanks to $$anonymous$$ike (whydoidoit) who have give me)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How i destroy the object of that part that collides with another object? 2 Answers

Shaders #pragma exclude 1 Answer

スクリプトが追加できません。,スクリプトクラスが見つからない (I can't add a script. , Script class not found) 0 Answers

How take a full res. Photo using webcam 0 Answers

Is it possible to have a changing line of script based off of variables? 0 Answers


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