本文整理汇总了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");
}
}
示例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;
}
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例9: UnityLight
public UnityLight(GameObject obj)
{
light = obj.GetComponent<Light>();
if (null == light) {
light = obj.AddComponent<Light>();
}
}
示例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);
}
}
}
示例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);
}
示例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");
}
示例13: Start
private void Start()
{
rndValue = UnityEngine.Random.value * 100.0f;
lightObject = GetComponent<Light>();
generate();
}
示例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");
}
}
示例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>();
}