public void SetFloat(WaterfallMaterial targetMat, string propertyName, float value) { foreach (var m in materials) { if (m == targetMat) { m.SetFloat(propertyName, value); if (modelTransforms.Count > 1) { foreach (var t in modelTransforms) { foreach (var r in t.GetComponentsInChildren <Renderer>()) { if (r.name == m.transformName) { if (propertyName == "_Seed" && m.useAutoRandomization) { } else { r.material.SetFloat(propertyName, value); } } } } } } } }
public void SetTextureOffset(WaterfallMaterial targetMat, string propertyName, Vector2 value) { foreach (WaterfallMaterial m in materials) { if (m == targetMat) { m.SetTextureOffset(propertyName, value); } } }
public void SetVector4(WaterfallMaterial targetMat, string propertyName, Vector4 value) { foreach (WaterfallMaterial m in materials) { if (m == targetMat) { m.SetVector4(propertyName, value); } } }
public void Initialize(Transform parent, bool fromNothing) { Utils.Log(String.Format("[WaterfallModel]: Instantiating model from {0} ", path), LogType.Effects); if (!GameDatabase.Instance.ExistsModel(path)) { Utils.LogError(String.Format("[WaterfallModel]: Unabled to find model {0} in GameDatabase", path)); } GameObject inst = GameObject.Instantiate(GameDatabase.Instance.GetModelPrefab(path), parent.position, parent.rotation); inst.SetLayerRecursive(1); inst.SetActive(true); Transform modelTransform = inst.GetComponent <Transform>(); modelTransform.SetParent(parent, true); //modelTransform.localScale = modelScaleOffset; //modelTransform.localPosition = modelPositionOffset; //if (modelRotationOffset == Vector3.zero) // modelTransform.localRotation = Quaternion.identity; //else // modelTransform.localEulerAngles = modelRotationOffset; //Utils.Log(String.Format("[WaterfallModel]: Instantiated model at {0} with {1}, {2}", modelPositionOffset, modelRotationOffset, modelScaleOffset)); modelTransforms.Add(modelTransform); Renderer[] renderers = modelTransform.GetComponentsInChildren <Renderer>(); if (fromNothing) { materials = new List <WaterfallMaterial>(); foreach (Renderer r in renderers) { WaterfallMaterial m = new WaterfallMaterial(); m.shaderName = overrideShader; m.materials = new List <Material>(); m.transformName = r.transform.name; materials.Add(m); } } foreach (WaterfallMaterial m in materials) { m.Initialize(modelTransform); } ApplyOffsets(modelPositionOffset, modelRotationOffset, modelScaleOffset); }
public void SetTexture(WaterfallMaterial targetMat, string propertyName, string value) { foreach (WaterfallMaterial m in materials) { if (m == targetMat) { m.SetTexture(propertyName, value); if (modelTransforms.Count > 1) { foreach (Transform t in modelTransforms) { foreach (Renderer r in t.GetComponentsInChildren <Renderer>()) { if (r.name == m.transformName) { r.material.SetTexture(propertyName, GameDatabase.Instance.GetTexture(value, false)); } } } } } } }
public void SetTextureOffset(WaterfallMaterial targetMat, string propertyName, Vector2 value) { foreach (var m in materials) { if (m == targetMat) { m.SetTextureOffset(propertyName, value); if (modelTransforms.Count > 1) { foreach (var t in modelTransforms) { foreach (var r in t.GetComponentsInChildren <Renderer>()) { if (r.name == m.transformName) { r.material.SetTextureOffset(propertyName, value); } } } } } } }
public void SetColor(WaterfallMaterial targetMat, string propertyName, Color value) { foreach (WaterfallMaterial m in materials) { if (m == targetMat) { m.SetColor(propertyName, value); if (modelTransforms.Count > 1) { foreach (Transform t in modelTransforms) { foreach (Renderer r in t.GetComponentsInChildren <Renderer>()) { if (r.name == m.transformName) { r.material.SetColor(propertyName, value); } } } } } } }
public void Initialize(Transform parent, bool fromNothing) { Utils.Log(String.Format("[WaterfallModel]: Instantiating model from {0} ", path), LogType.Effects); if (!GameDatabase.Instance.ExistsModel(path)) { Utils.LogError(String.Format("[WaterfallModel]: Unabled to find model {0} in GameDatabase", path)); } var inst = Object.Instantiate(GameDatabase.Instance.GetModelPrefab(path), parent.position, parent.rotation); inst.SetLayerRecursive(1); inst.SetActive(true); var modelTransform = inst.GetComponent <Transform>(); modelTransform.SetParent(parent, true); //modelTransform.localScale = modelScaleOffset; //modelTransform.localPosition = modelPositionOffset; //if (modelRotationOffset == Vector3.zero) // modelTransform.localRotation = Quaternion.identity; //else // modelTransform.localEulerAngles = modelRotationOffset; //Utils.Log(String.Format("[WaterfallModel]: Instantiated model at {0} with {1}, {2}", modelPositionOffset, modelRotationOffset, modelScaleOffset)); modelTransforms.Add(modelTransform); var renderers = modelTransform.GetComponentsInChildren <Renderer>(); var lightObjs = modelTransform.GetComponentsInChildren <Light>(); if (fromNothing) { materials = new(); lights = new(); if (lightObjs.Length > 0) { var l = new WaterfallLight(); l.lights = new(); l.transformName = lightObjs[0].name; lights.Add(l); } foreach (var r in renderers) { var m = new WaterfallMaterial(); if (overrideShader != null) { m.shaderName = overrideShader; } m.useAutoRandomization = randomized; m.materials = new(); m.transformName = r.transform.name; materials.Add(m); } } foreach (var m in materials) { m.useAutoRandomization = randomized; m.Initialize(modelTransform); } foreach (var l in lights) { l.Initialize(modelTransform); } ApplyOffsets(modelPositionOffset, modelRotationOffset, modelScaleOffset); }