// Called when the mouse begins hovering an editable object.
        internal override void OnBrushEnter(EditableObject target, BrushSettings settings)
        {
            base.OnBrushEnter(target, settings);

            if (target.editMesh == null)
            {
                return;
            }

            bool refresh = (m_MainCacheTarget != null && !m_MainCacheTarget.Equals(target)) || m_MainCacheTarget == null;

            if (m_MainCacheTarget != null && m_MainCacheTarget.Equals(target))
            {
                var targetMaterials = target.gameObjectAttached.GetMaterials();
                refresh = !targetMaterials.SequenceEqual(m_MainCacheMaterials);
            }

            if (refresh)
            {
                SetActiveObject(target);
                RebuildMaterialCaches();
                PolybrushEditor.instance.Repaint();
            }

            if (m_LikelySupportsTextureBlending && (brushColor == null || !brushColor.MatchesAttributes(meshAttributes)))
            {
                brushColor = new SplatWeight(SplatWeight.GetChannelMap(meshAttributes));
                SetBrushColorWithAttributeIndex(selectedAttributeIndex);
            }
            RebuildColorTargets(target, brushColor, settings.strength);
        }
        // Called when the mouse begins hovering an editable object.
        internal override void OnBrushEnter(EditableObject target, BrushSettings settings)
        {
            base.OnBrushEnter(target, settings);

            if (target.editMesh == null)
            {
                return;
            }

            bool refresh = (m_CacheTarget != null && !m_CacheTarget.Equals(target)) || m_CacheTarget == null;

            if (m_CacheTarget != null && m_CacheTarget.Equals(target.gameObjectAttached))
            {
                var targetMaterials = target.gameObjectAttached.GetMaterials();
                refresh = !AreListsEqual(targetMaterials, m_CacheMaterials);
            }

            if (refresh)
            {
                m_CacheTarget             = target;
                m_CacheMaterials          = target.gameObjectAttached.GetMaterials();
                m_MeshAttributesContainer = null;
                currentMeshACIndex        = 0;
                ArrayUtility.Clear(ref m_AvailableMaterialsAsString);
                m_LikelySupportsTextureBlending = CheckForTextureBlendSupport(target.gameObjectAttached);
                RebuildCaches(target.editMesh);
            }

            if (m_LikelySupportsTextureBlending && (brushColor == null || !brushColor.MatchesAttributes(meshAttributes)))
            {
                brushColor = new SplatWeight(SplatWeight.GetChannelMap(meshAttributes));
                SetBrushColorWithAttributeIndex(selectedAttributeIndex);
            }
            RebuildColorTargets(brushColor, settings.strength);
        }
示例#3
0
        /// <summary>
        /// Will ensure that the check is not done everytime (inspired from BrushModeTexture script)
        /// </summary>
        /// <param name="target"></param>
        void RefreshVertexSculptSupport(EditableObject target)
        {
            bool refresh = (cache_target != null && !cache_target.Equals(target.gameObjectAttached)) || cache_target == null;

            if (cache_target != null && cache_target.Equals(target.gameObjectAttached))
            {
                refresh = cache_materials != target.gameObjectAttached.GetMaterials();
            }

            if (refresh)
            {
                cache_target                = target;
                cache_materials             = target.gameObjectAttached.GetMaterials();
                likelyToSupportVertexSculpt = CheckForVertexScluptSupport(target.gameObjectAttached);
            }
        }