I am new to Unity and C# (started last month) and I am working on a project with 2 other people, I am learning about Unity and C# as I go along and we came across 2 errors that we can’t seem to fix… (shown below)
So I thought to ask the Unity Community for help, I have included the scripts as well.
SpecularLighting:
using System;
using UnityEngine;
namespace UnityStandardAssets.WaterBase
{
[RequireComponent(typeof(WaterBase))]
[ExecuteInEditMode]
public class SpecularLighting : MonoBehaviour
{
public Transform SpecularLight;
public WaterBase m_WaterBase;
public void Start()
{
m_WaterBase = (WaterBase)gameObject.GetComponent(typeof(WaterBase));
}
public void Update()
{
if (!m_WaterBase)
{
m_WaterBase = (WaterBase)gameObject.GetComponent(typeof(WaterBase));
}
if (SpecularLight && m_WaterBase.sharedMaterial)
{
m_WaterBase.sharedMaterial.SetVector("_WorldLightDir", SpecularLight.transform.forward);
}
}
}
}
WaterTile:
using System;
using UnityEngine;
namespace UnityStandardAssets.Water
{
[ExecuteInEditMode]
public class WaterTile : MonoBehaviour
{
public PlanarReflection reflection;
public WaterBase waterBase;
public void Start()
{
AcquireComponents();
}
void AcquireComponents()
{
if (!reflection)
{
if (transform.parent)
{
reflection = transform.parent.GetComponent<PlanarReflection>();
}
else
{
reflection = transform.GetComponent<PlanarReflection>();
}
}
if (!waterBase)
{
if (transform.parent)
{
waterBase = transform.parent.GetComponent<WaterBase>();
}
else
{
waterBase = transform.GetComponent<WaterBase>();
}
}
}
#if UNITY_EDITOR
public void Update()
{
AcquireComponents();
}
#endif
public void OnWillRenderObject()
{
if (reflection)
{
reflection.WaterTileBeingRendered(transform, Camera.current);
}
if (waterBase)
{
waterBase.WaterTileBeingRendered(transform, Camera.current);
}
}
}
}
