create LightSource script

This commit is contained in:
in0finite 2021-04-18 00:07:49 +02:00
parent 0a3a11a5e0
commit f87eb89c63
3 changed files with 36 additions and 3 deletions

View file

@ -0,0 +1,24 @@
using SanAndreasUnity.Importing.RenderWareStream;
using UnityEngine;
namespace SanAndreasUnity.Behaviours.World
{
public class LightSource : MonoBehaviour
{
public TwoDEffect.Light LightInfo { get; private set; }
public static LightSource Create(
Transform parent,
TwoDEffect.Light lightInfo)
{
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
go.transform.SetParent(parent);
go.transform.localPosition = lightInfo.Position;
var lightSource = go.AddComponent<LightSource>();
lightSource.LightInfo = lightInfo;
return lightSource;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b9d0e4e930be6b418ff0ddaff0600f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -202,9 +202,7 @@ namespace SanAndreasUnity.Behaviours.World
{
foreach (var lightInfo in geometry.TwoDEffect.Lights)
{
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
go.transform.SetParent(tr);
go.transform.localPosition = lightInfo.Position;
LightSource.Create(tr, lightInfo);
}
}
}