Esempio n. 1
0
        public void UpdateReceiver()
        {
#if UNITY_EDITOR
            if (!m_bAwoken || m_projector == null)
            {
                Awake();
            }
            if (m_projector == null)
            {
                return;
            }
            if (!m_bStarted)
            {
                Start();
            }
#endif
            if (m_projector != null && (Debug.isDebugBuild || Application.isEditor))
            {
                if (m_projector is UnityProjector)
                {
                    UnityProjector projector = m_projector as UnityProjector;
                    if ((projector.projector.ignoreLayers & (1 << gameObject.layer)) != 0)
                    {
                        Debug.LogWarning("Ignore layers of the projector contains the layer of this shadow receiver. Shadow won't be rendered.", this);
                    }
                }
            }
            OnUpdate();
        }
Esempio n. 2
0
        private void Awake()
        {
            m_projector = new UnityProjector(GetComponent <Projector>());
            // check if the components of this game object have UpdateTransform methods
            var components = gameObject.GetComponents <Component>();

            for (var i = 0; i < components.Length; ++i)
            {
                var type   = components[i].GetType();
                var method = type.GetMethod("UpdateTransform");
                if (method != null)
                {
                    m_projector.updateTransform +=
                        Delegate.CreateDelegate(typeof(Action), components[i], method) as Action;
                }
            }
            m_transform = transform;
            m_vertices  = new Vector3[4];
            if (m_projector.projector.material.HasProperty(SHADOW_ALPHA_PROPERTY_NAME))
            {
                m_projector.projector.material = new Material(m_projector.projector.material);
                // make a copy of material so that we can change alpha later.
                m_originalAlpha = m_projector.projector.material.GetFloat(SHADOW_ALPHA_PROPERTY_NAME);
                m_canFadeout    = true;
            }
            else
            {
                m_originalAlpha = 1.0f;
                m_canFadeout    = false;
            }
        }