- Home /
 
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
what are?
what they do?
when do use?
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;
  }
  }
 }
 
              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.
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
 
             Follow this Question
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