SanAndreasUnity/Assets/Scripts/Behaviours/World/LightSource.cs

40 lines
1.4 KiB
C#
Raw Normal View History

2021-06-25 12:37:24 +00:00
using System;
2021-06-25 16:56:52 +00:00
using System.Collections;
2021-06-25 12:37:24 +00:00
using SanAndreasUnity.Importing.RenderWareStream;
using SanAndreasUnity.Utilities;
2021-04-17 22:07:49 +00:00
using UnityEngine;
2021-06-25 12:37:24 +00:00
using TextureDictionary = SanAndreasUnity.Importing.Conversion.TextureDictionary;
2021-04-17 22:07:49 +00:00
namespace SanAndreasUnity.Behaviours.World
{
public class LightSource : MonoBehaviour
{
public TwoDEffect.Light LightInfo { get; private set; }
public static LightSource Create(
Transform parent,
TwoDEffect.Light lightInfo)
{
2021-06-25 12:37:24 +00:00
var go = Instantiate(Cell.Instance.lightSourcePrefab, parent);
go.transform.localPosition = lightInfo.Position;
go.transform.localScale = Vector3.one * lightInfo.CoronaSize * Cell.Instance.lightScaleMultiplier;
var lightSource = go.GetComponentOrThrow<LightSource>();
lightSource.LightInfo = lightInfo;
var spriteRenderer = go.GetComponentOrThrow<SpriteRenderer>();
// var texture = TextureDictionary.Load("particle")
// .GetDiffuse(lightInfo.CoronaTexName)
// .Texture;
// var sprite = Sprite.Create(
// texture,
// new Rect(0, 0, texture.width, texture.height),
// new Vector2(0.5f, 0.5f));
// spriteRenderer.sprite = sprite;
spriteRenderer.color = lightInfo.Color;
return lightSource;
}
2021-04-17 22:07:49 +00:00
}
}