Exemplo n.º 1
0
        private void SetTPMat()
        {
            LImageForTP image = target as LImageForTP;

            if (!m_UseTPAtlas.boolValue)
            {
                if (m_UseTPAtlas.boolValue != image.m_UseTPAtlas)
                {
                    m_Material.objectReferenceValue = null;
                    m_Sprite.objectReferenceValue   = null;
                }
            }
            else
            {
                if (m_UseTPAtlas.boolValue != image.m_UseTPAtlas)
                {
                    string sprName = m_Sprite.objectReferenceValue ? m_Sprite.objectReferenceValue.name : "";
                    Debug.Log("m_UseTPAtlas change:" + sprName);
                    ResetSpriteByName(sprName);
                }
                else
                {
                    if (m_Sprite.objectReferenceValue != _lastSprite)
                    {
                        string sprName = m_Sprite.objectReferenceValue ? m_Sprite.objectReferenceValue.name : "";
                        Debug.Log("m_Sprite change:" + sprName);
                        ResetSpriteByName(sprName);
                        _lastSprite     = m_Sprite.objectReferenceValue as Sprite;
                        _lastSpriteName = sprName;
                    }
                    else if (!string.IsNullOrEmpty(m_SpriteName.stringValue) && !_lastSpriteName.Equals(m_SpriteName.stringValue))
                    {
                        string sprName = m_SpriteName.stringValue;
                        Debug.Log("m_SpriteName change:" + sprName);
                        ResetSpriteByName(sprName);
                        _lastSprite     = m_Sprite.objectReferenceValue as Sprite;
                        _lastSpriteName = sprName;
                    }
                    else if (m_Material.objectReferenceValue == null)
                    {
                        string sprName = m_SpriteName.stringValue;
                        ResetSpriteByName(sprName);
                        _lastSprite     = m_Sprite.objectReferenceValue as Sprite;
                        _lastSpriteName = sprName;
                    }
                }
            }
        }
Exemplo n.º 2
0
        static void LImage2LImageForTP(MenuCommand menuCommand)
        {
            LImage     image         = menuCommand.context as LImage;
            GameObject go            = image.gameObject;
            var        color         = image.color;
            var        sprite        = image.sprite;
            var        raycastTarget = image.raycastTarget;

            var type = image.type;

            GameObject.DestroyImmediate(image);

            LImageForTP image2 = go.AddComponent <LImageForTP>();

            image2.color         = color;
            image2.sprite        = sprite;
            image2.raycastTarget = raycastTarget;
            image2.type          = type;
        }