コード例 #1
0
        public void SetLightType(WaterfallLight targetLight, LightType value)
        {
            foreach (var l in lights)
            {
                if (l == targetLight)
                {
                    l.SetLightType(value);

                    if (modelTransforms.Count > 1)
                    {
                        foreach (var t in modelTransforms)
                        {
                            foreach (var li in t.GetComponentsInChildren <Light>())
                            {
                                li.type = value;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void SetLightIntensity(WaterfallLight targetLight, float value)
        {
            foreach (var l in lights)
            {
                if (l == targetLight)
                {
                    l.SetIntensity(value);

                    if (modelTransforms.Count > 1)
                    {
                        foreach (var t in modelTransforms)
                        {
                            foreach (var li in t.GetComponentsInChildren <Light>())
                            {
                                li.intensity = value;
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        public void SetLightColor(WaterfallLight targetLight, Color value)
        {
            foreach (WaterfallLight l in lights)
            {
                if (l == targetLight)
                {
                    l.SetColor(value);

                    if (modelTransforms.Count > 1)
                    {
                        foreach (Transform t in modelTransforms)
                        {
                            foreach (Light li in t.GetComponentsInChildren <Light>())
                            {
                                li.color = value;
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public void SetLightAngle(WaterfallLight targetLight, float value)
        {
            foreach (WaterfallLight l in lights)
            {
                if (l == targetLight)
                {
                    l.SetAngle(value);

                    if (modelTransforms.Count > 1)
                    {
                        foreach (Transform t in modelTransforms)
                        {
                            foreach (Light li in t.GetComponentsInChildren <Light>())
                            {
                                li.spotAngle = value;
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        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);
        }