當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.Light類代碼示例

本文整理匯總了C#中UnityEngine.Light的典型用法代碼示例。如果您正苦於以下問題:C# Light類的具體用法?C# Light怎麽用?C# Light使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Light類屬於UnityEngine命名空間,在下文中一共展示了Light類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Awake

 public void Awake()
 {
     this.light = GetComponentInChildren<Light>();
     if (light == null) {
         throw new MissingComponentException("Light Component required for AmbientFire");
     }
 }
開發者ID:Dawnwoodgames,項目名稱:LotsOfTowers,代碼行數:7,代碼來源:AmbientFire.cs

示例2: Start

    // Use this for initialization
    void Start()
    {
        m_currentRange = MaxRange;
        m_stepSize = FlickerSpeed;
        m_currentLightCharge = LightCharge;

        if (LightPrefab)
        {
            SkinnedMeshRenderer mesh = GameObject.Find("Body_Lowpoly").GetComponent<SkinnedMeshRenderer>();
            Transform parentTransform = mesh.bones[9].transform;
            parentTransform = parentTransform.transform.FindChild("Bip001 Spine2");
            parentTransform = parentTransform.transform.FindChild("Bip001 Spine3");
            parentTransform = parentTransform.transform.FindChild("Bone017");
            parentTransform = parentTransform.transform.FindChild("Bone018");
            parentTransform = parentTransform.transform.FindChild("connectBone001");
            parentTransform = parentTransform.transform.FindChild("Bone030");
            parentTransform = parentTransform.transform.FindChild("LightAttatchBone");

            GameObject obj = (GameObject)Instantiate(LightPrefab, Vector3.zero, Quaternion.identity);
            m_light = obj.GetComponent<Light>().light;
            m_light.transform.parent = parentTransform;
            m_light.transform.localPosition = Vector3.zero;
            m_light.color = LightColor;
            m_light.range = MaxRange;
            m_light.intensity = MaxIntensity;
        }
    }
開發者ID:SamOatesUniversity,項目名稱:Year-3---Group-Project---Flicker,代碼行數:28,代碼來源:CPlayerLight.cs

示例3: Start

		void Start()
		{
			startTime = Time.time;
			pEmitters = gameObject.GetComponentsInChildren<KSPParticleEmitter>();
			foreach(KSPParticleEmitter pe in pEmitters)
			{
				pe.emit = true;	
				pe.force = (4.49f * FlightGlobals.getGeeForceAtPosition(transform.position));
				if(pe.maxEnergy > maxTime)
				{
					maxTime = pe.maxEnergy;	
				}
			}
			lightFX = gameObject.AddComponent<Light>();
			lightFX.color = Misc.ParseColor255("255,238,184,255");
			lightFX.intensity = 8;
			lightFX.range = 50;
			
			exSound = GameDatabase.Instance.GetAudioClip("BDArmory/Sounds/explode1");
			audioSource = gameObject.AddComponent<AudioSource>();
			audioSource.minDistance = 20;
			audioSource.maxDistance = 1000;
			audioSource.volume = Mathf.Sqrt(GameSettings.SHIP_VOLUME);
			audioSource.PlayOneShot(exSound);
		}
開發者ID:kevincoggins,項目名稱:BDArmory,代碼行數:25,代碼來源:ExplosionFX.cs

示例4: OnEnable

    private void OnEnable()
    {
      lightModes = new string[2];
      lightModes[0] = @"UnLit";
      lightModes[1] = @"BumpLit";

      spriteRenderer = this.GetComponent<SpriteRenderer>();

      sunLight = this.GetComponent<Light>();

      hsbColor = new HSBColor(Color.white);
      hsbColor.s = 1.0f;

      if (GameObject.Find("FlareSpawner0") != null)
      {
        flareSpawners.Add(GameObject.Find("FlareSpawner0").GetComponent<Spawner>());
        flareSpawners[0].enabled = false;
      }

      if (GameObject.Find("FlareSpawner1") != null)
      {
        flareSpawners.Add(GameObject.Find("FlareSpawner1").GetComponent<Spawner>());
        flareSpawners[1].enabled = false;
      }

      if (GameObject.Find("FlareSpawner2") != null)
      {
        flareSpawners.Add(GameObject.Find("FlareSpawner2").GetComponent<Spawner>());
        flareSpawners[2].enabled = false;
      }
    }
開發者ID:zacharymacleod,項目名稱:Betrayer,代碼行數:31,代碼來源:Sun.cs

示例5: GenerateShadowsGenerator

        private void GenerateShadowsGenerator(Light light)
        {
            var generator = new BabylonShadowGenerator
            {
                lightId = GetID(light.gameObject),
                usePoissonSampling = light.shadows == LightShadows.Soft,
                mapSize = 256 + 256 * QualitySettings.GetQualityLevel(),
                bias = light.shadowBias / 10.0f
            };

            var renderList = new List<string>();
            foreach (var gameObject in gameObjects)
            {
                var meshFilter = gameObject.GetComponent<MeshFilter>();
                var renderer = gameObject.GetComponent<Renderer>();
                if (meshFilter != null && renderer != null && renderer.shadowCastingMode != ShadowCastingMode.Off)
                {
                    renderList.Add(GetID(gameObject));
                    continue;
                }

                var skinnedMesh = gameObject.GetComponent<SkinnedMeshRenderer>();
                if (skinnedMesh != null && renderer != null && renderer.shadowCastingMode != ShadowCastingMode.Off)
                {
                    renderList.Add(GetID(gameObject));
                }
            }

            generator.renderList = renderList.ToArray();

            babylonScene.ShadowGeneratorsList.Add(generator);
        }
開發者ID:CallmeNezha,項目名稱:Babylon.js,代碼行數:32,代碼來源:SceneBuilder.Lights.cs

示例6: MeshViewer

        private MeshViewer()
            : base("Mesh Viewer", new Rect(512, 128, 512, 512), skin)
        {
            onDraw = DrawWindow;

            material = new Material(Shader.Find("Diffuse"));

            try
            {
                light = GameObject.Find("Directional Light").GetComponent<Light>();
            }
            catch (Exception)
            {
                light = null;
            }

            meshViewerCamera = gameObject.AddComponent<Camera>();
            meshViewerCamera.transform.position = new Vector3(-10000.0f, -10000.0f, -10000.0f);
            meshViewerCamera.fieldOfView = 20.0f;
            meshViewerCamera.backgroundColor = Color.grey;
            meshViewerCamera.nearClipPlane = 1.0f;
            meshViewerCamera.farClipPlane = 1000.0f;
            meshViewerCamera.enabled = false;

            targetRT = new RenderTexture(512, 512, 24, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
            meshViewerCamera.targetTexture = targetRT;
        }
開發者ID:Rychard,項目名稱:Skylines-ModTools,代碼行數:27,代碼來源:MeshViewer.cs

示例7: SetColor

 void SetColor(Transform _transform, Color _color)
 {
     mText = _transform.GetComponent<Text> ();
     if (mText != null){
         mText.color = _color;
     }
     mLight = _transform.GetComponent<Light>();
     if (mLight != null){
         mLight.color = _color;
     }
     mImage = _transform.GetComponent<Image> ();
     if (mImage != null) {
         mImage.color = _color;
     }
     mSpriteRender = _transform.GetComponent<SpriteRenderer> ();
     if (mSpriteRender != null) {
         mSpriteRender.color = _color;
     }
     if (_transform.GetComponent<Renderer>() != null) {
         mMat = _transform.GetComponent<Renderer>().material;
         if (mMat != null) {
             mMat.color = _color;
         }
     }
     if (includeChilds) {
         for (int i = 0; i < _transform.childCount; ++i) {
             Transform child = _transform.GetChild(i);
             SetColor(child, _color);
         }
     }
 }
開發者ID:nekodon,項目名稱:Pinball,代碼行數:31,代碼來源:uTweenColor.cs

示例8: ApplyAOLight

 void ApplyAOLight(ref Color c, Light l, Vector3 pos, Vector3 n)
 {
    if (!l.isActiveAndEnabled)
       return;
    Vector3 dir;
    float intensity = l.intensity;
    if (l.type == LightType.Directional)
    {
       dir = -l.transform.forward;
    }
    else if (l.type == LightType.Point)
    {
       dir = (l.transform.position - pos).normalized;
       intensity *= Mathf.Clamp01((l.range - Vector3.Distance(l.transform.position, pos)) / l.range);
    }
    else
    {
       return;
    }
    
    intensity *= Mathf.Clamp01(Vector3.Dot(n, dir));
   
    c.r += l.color.r * intensity;
    c.g += l.color.g * intensity;
    c.b += l.color.b * intensity;
 }
開發者ID:ArieLeo,項目名稱:VertexPaint,代碼行數:26,代碼來源:VertexPainterWindow_AO.cs

示例9: UnityLight

 public UnityLight(GameObject obj)
 {
     light = obj.GetComponent<Light>();
     if (null == light) {
         light = obj.AddComponent<Light>();
     }
 }
開發者ID:ZackGill,項目名稱:Uniject,代碼行數:7,代碼來源:UnityLight.cs

示例10: ConvertUnityLightToBabylon

        private void ConvertUnityLightToBabylon(Light light, float progress)
        {
            if (!light.isActiveAndEnabled || light.alreadyLightmapped)
            {
                return;
            }

            ExporterWindow.ReportProgress(progress, "Exporting light: " + light.name);

            BabylonLight babylonLight = new BabylonLight
            {
                name = light.name,
                id = GetID(light.gameObject),
                parentId = GetParentID(light.transform)
            };
            
            switch (light.type)
            {
                case LightType.Spot:
                    babylonLight.type = 2;
                    break;
                case LightType.Directional:
                    babylonLight.type = 1;
                    break;
                case LightType.Point:
                    babylonLight.type = 0;
                    babylonLight.range = light.range;
                    break;
                case LightType.Area:
                    // TODO
                    break;
            }

            babylonLight.position = light.transform.localPosition.ToFloat();

            var direction = new Vector3(0, 0, 1);
            var transformedDirection = light.transform.TransformDirection(direction);
            babylonLight.direction = transformedDirection.ToFloat();

            babylonLight.diffuse = light.color.ToFloat();

            babylonLight.intensity = light.intensity;

            babylonLight.angle = light.spotAngle * (float)Math.PI / 180;
            babylonLight.exponent = 1.0f;

            babylonScene.LightsList.Add(babylonLight);

            // Animations
            ExportAnimations(light.transform, babylonLight);

            // Shadows
            if (exportationOptions.ExportShadows)
            {
                if ((light.type == LightType.Directional || light.type == LightType.Spot) && light.shadows != LightShadows.None)
                {
                    GenerateShadowsGenerator(light);
                }
            }
        }
開發者ID:ZackMFleischman,項目名稱:Babylon.js,代碼行數:60,代碼來源:SceneBuilder.Lights.cs

示例11: Start

		void Start()
		{
			startTime = Time.time;
			pEmitters = gameObject.GetComponentsInChildren<KSPParticleEmitter>();
			foreach(KSPParticleEmitter pe in pEmitters)
			{
				pe.emit = true;	

				//if(pe.useWorldSpace) pe.force = (4.49f * FlightGlobals.getGeeForceAtPosition(transform.position));

				if(pe.maxEnergy > maxTime)
				{
					maxTime = pe.maxEnergy;	
				}
			}
			lightFX = gameObject.AddComponent<Light>();
			lightFX.color = Misc.ParseColor255("255,238,184,255");
			lightFX.intensity = 8;
			lightFX.range = range*3f;
			lightFX.shadows = LightShadows.None;
			
			
			
			audioSource.volume = BDArmorySettings.BDARMORY_WEAPONS_VOLUME;
			
			audioSource.PlayOneShot(exSound);
		}
開發者ID:BahamutoD,項目名稱:BDArmory,代碼行數:27,代碼來源:ExplosionFX.cs

示例12: Start

		void Start () {
			spotLight = spotRotater.GetComponent<Light>();
			pixels = new Color[resolution * resolution];

			// Generate color map.
			Texture2D colorMapTexture = new Texture2D(32, 1, TextureFormat.ARGB32, false);
			colorMapTexture.wrapMode = TextureWrapMode.Clamp;
			colorMapDiagram.Fill(pixels, 32, 1);
			colorMapTexture.SetPixels(pixels);
			colorMapTexture.Apply();
			
			terrainTexture = new Texture2D(resolution, resolution, TextureFormat.ARGB32, false);
			terrainTexture.wrapMode = TextureWrapMode.Repeat;
			terrainTexture.name = "Dynamic Terrain";
			terrainMesh.Generate(resolution);
			
			// Fetch materials, set textures, and read initial settings.
			terrainMaterial = terrainMesh.materials[0];
			waterMaterial = terrainMesh.materials[1];
			
			waterMaterial.mainTexture = terrainMaterial.mainTexture = terrainTexture;
			terrainMaterial.SetTexture("_ColorMap", colorMapTexture);
			
			morphValue = heightFieldDiagram.GetInputValue("Morph");
			octavesValue = heightFieldDiagram.GetInputValue("Octaves");
			persistenceValue = heightFieldDiagram.GetInputValue("Persistence");
			secondary = heightFieldDiagram.GetInputValue("Secondary");
		}
開發者ID:indigo,項目名稱:indigo,代碼行數:28,代碼來源:TerrainController.cs

示例13: Start

        private void Start()
        {
            rndValue = UnityEngine.Random.value * 100.0f;
            lightObject = GetComponent<Light>();

            generate();
        }
開發者ID:Baensi,項目名稱:Assets,代碼行數:7,代碼來源:FireLightPro.cs

示例14: UnityLight

 public UnityLight(IGameObject obj)
     : base(obj)
 {
     light = obj.GetComponent<Light>();
     if (null == light) {
         throw new NullReferenceException("Object " + obj.Name  + " expected to have Light but none was found");
     }
 }
開發者ID:gturk,項目名稱:Uniject,代碼行數:8,代碼來源:UnityLight.cs

示例15: Start

 private void Start()
 {
     m_Rnd = Random.value;
     if(m_Rnd < 0.5f)
         m_Rnd = 0.5f;
     m_Rnd *= 25;
     m_Light = GetComponent<Light>();
 }
開發者ID:mauffine,項目名稱:BattleOfTheBards,代碼行數:8,代碼來源:FireLight.cs


注:本文中的UnityEngine.Light類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。