Esempio n. 1
0
 /// <summary>
 /// Update the beam material and its bounds.
 /// Calling manually this function is useless if your beam has its property 'trackChangesDuringPlaytime' enabled
 /// (because then this function is automatically called each frame).
 /// However, if 'trackChangesDuringPlaytime' is disabled, and you change a property via Script for example,
 /// you need to call this function to take the property change into account.
 /// All properties changes are took into account, expect 'geomSides' and 'geomCap' which require to regenerate the geometry via 'GenerateGeometry()'
 /// </summary>
 public virtual void UpdateAfterManualPropertyChange()
 {
     ValidateProperties();
     if (m_BeamGeom)
     {
         m_BeamGeom.UpdateMaterialAndBounds();
     }
 }
Esempio n. 2
0
        void Update() // EDITOR ONLY
        {
            // Handle edition of light properties in Editor
            if (!Application.isPlaying)
            {
                var newProps = new CachedLightProperties(lightSpotAttached);
                if (!newProps.Equals(m_PrevCachedLightProperties))
                {
                    m_EditorDirtyFlags |= EditorDirtyFlags.Props;
                }
                m_PrevCachedLightProperties = newProps;
            }

            if (m_EditorDirtyFlags == EditorDirtyFlags.Clean)
            {
                if (Application.isPlaying)
                {
                    if (!trackChangesDuringPlaytime) // during Playtime, realtime changes are handled by CoUpdateDuringPlaytime
                    {
                        return;
                    }
                }
            }
            else
            {
                if (m_EditorDirtyFlags.HasFlag(EditorDirtyFlags.Mesh))
                {
                    GenerateGeometry(); // regenerate everything
                }
                else if (m_EditorDirtyFlags.HasFlag(EditorDirtyFlags.Props))
                {
                    AssignPropertiesFromSpotLight(lightSpotAttached);
                    ValidateProperties();
                }
            }

            // If we modify the attached Spotlight properties, or if we animate the beam via Unity 2017's timeline,
            // we are not notified of properties changes. So we update the material anyway.
            if (m_BeamGeom)
            {
                m_BeamGeom.UpdateMaterialAndBounds();
            }

            m_EditorDirtyFlags = EditorDirtyFlags.Clean;
        }
Esempio n. 3
0
        /// <summary>
        /// Update the beam material and its bounds.
        /// Calling manually this function is useless if your beam has its property 'trackChangesDuringPlaytime' enabled
        /// (because then this function is automatically called each frame).
        /// However, if 'trackChangesDuringPlaytime' is disabled, and you change a property via Script for example,
        /// you need to call this function to take the property change into account.
        /// All properties changes are took into account, expect 'geomSides' and 'geomCap' which require to regenerate the geometry via 'GenerateGeometry()'
        /// </summary>
        public void UpdateAfterManualPropertyChange()
        {
            if (QuadRenderer)
            {
                var block = QuadRenderer.GetComponent <Renderer>().GetPropertyBlock();
                block.SetColor("_Color", this.color);
                QuadRenderer.GetComponent <Renderer>().SetPropertyBlock(block);
            }

            if (m_BeamGeom)
            {
                m_BeamGeom.UpdateMaterialAndBounds();
            }
            if (m_BeamGeom_back)
            {
                m_BeamGeom_back.UpdateMaterialAndBounds();
            }
        }