예제 #1
0
    /// <summary>
    /// Replacement atlas selection callback.
    /// </summary>

    void OnSelectAtlas(Object obj)
    {
        // Legacy atlas support
        if (obj != null && obj is GameObject)
        {
            obj = (obj as GameObject).GetComponent <UIAtlas>();
        }

        var rep = obj as INGUIAtlas;

        if (mReplacement != rep)
        {
            // Undo doesn't work correctly in this case... so I won't bother.
            //NGUIEditorTools.RegisterUndo("Atlas Change");
            //NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);

            mAtlas.replacement = rep;
            mReplacement       = mAtlas.replacement;
            NGUITools.SetDirty(mAtlas as Object);
            if (mReplacement == null)
            {
                mType = AtlasType.Normal;
            }
        }
    }
예제 #2
0
파일: UICursor.cs 프로젝트: HMu0510/NGUIP
    /// <summary>
    /// Override the cursor with the specified sprite.
    /// </summary>

    static public void Set(INGUIAtlas atlas, string sprite)
    {
        if (instance != null && instance.mSprite)
        {
            instance.mSprite.atlas      = atlas;
            instance.mSprite.spriteName = sprite;
            instance.mSprite.MakePixelPerfect();
            instance.Update();
        }
    }
예제 #3
0
 // Token: 0x060000D9 RID: 217 RVA: 0x000118B8 File Offset: 0x0000FAB8
 public static void Set(INGUIAtlas atlas, string sprite)
 {
     if (UICursor.instance != null && UICursor.instance.mSprite)
     {
         UICursor.instance.mSprite.atlas      = atlas;
         UICursor.instance.mSprite.spriteName = sprite;
         UICursor.instance.mSprite.MakePixelPerfect();
         UICursor.instance.Update();
     }
 }
예제 #4
0
 static public void Draw(string buttonName, INGUIAtlas atlas, OnSelectionCallback cb, bool editButton, params GUILayoutOption[] options)
 {
     if (atlas is UIAtlas)
     {
         Draw(buttonName, atlas as UIAtlas, cb, editButton, options);
     }
     else
     {
         Draw(buttonName, atlas as NGUIAtlas, cb, editButton, options);
     }
 }
예제 #5
0
    /// <summary>
    /// Show the selection wizard.
    /// </summary>

    static public void Show(INGUIAtlas atlas, OnSelectionCallback cb)
    {
        if (atlas is UIAtlas)
        {
            Show <UIAtlas>(cb, new string[] { ".prefab" });
        }
        else
        {
            Show <NGUIAtlas>(cb, new string[] { ".asset" });
        }
    }
예제 #6
0
        public static string name(this INGUIAtlas atlas)
        {
            switch (atlas)
            {
            case NGUIAtlas a:
                return(a.name);

            case UIAtlas at:
                return(at.name);

            default:
                return(atlas.ToString());
            }
        }
예제 #7
0
        public static NGUIAtlas origin(this INGUIAtlas atlas)
        {
            switch (atlas)
            {
            case NGUIAtlas a:
                return(a);

            case UIAtlas at:
                return(at.replacement.origin());

            default:
                return(null);
            }
        }
예제 #8
0
        public static NGUIAtlas Clone(this INGUIAtlas a, string shaderName)
        {
            NGUIAtlas b = Object.Instantiate(a.origin());

            Object.DontDestroyOnLoad(b);
            if (b.replacement != null)
            {
                b.replacement = Object.Instantiate(b.origin());
                Object.DontDestroyOnLoad(b.origin());
            }
            b.spriteMaterial = Object.Instantiate(b.spriteMaterial);
            Object.DontDestroyOnLoad(b.spriteMaterial);
            b.spriteMaterial.shader = Shader.Find(shaderName);
            return(b);
        }
예제 #9
0
        private void OnSelectAtlas(Object obj)
        {
            atlas = NGUISettings.atlas = obj as INGUIAtlas;

            UISprite[] sprites = sceneRoot.GetComponentsInChildren <UISprite>(true);
            spriteMap = new MultiMap <string, UISprite>();
            foreach (UISprite s in sprites)
            {
                if (s.atlas == atlas)
                {
                    spriteMap.Add(s.spriteName, s);
                }
            }
            Repaint();
        }
예제 #10
0
        public static void SplitChannelETC(INGUIAtlas atlas)
        {
            while (atlas.replacement != null)
            {
                atlas = atlas.replacement;
            }
            if (atlas.spriteMaterial.shader.name == ShaderId.UI)
            {
                throw new NotImplementedException("Atlas size cannot be set");
//                atlas.width = atlas.spriteMaterial.mainTexture.width;
//                atlas.height = atlas.spriteMaterial.mainTexture.height;
            }
            SplitChannelETC(atlas.spriteMaterial);
            EditorUtil.SetDirty(atlas as Object);
        }
예제 #11
0
    /// <summary>
    /// Parse the specified JSon file, loading sprite information for the specified atlas.
    /// </summary>

    static public void LoadSpriteData(INGUIAtlas atlas, string jsonData)
    {
        if (string.IsNullOrEmpty(jsonData) || atlas == null)
        {
            return;
        }

        Hashtable decodedHash = jsonDecode(jsonData) as Hashtable;

        if (decodedHash == null)
        {
            Debug.LogWarning("Unable to parse the provided Json string");
        }
        else
        {
            LoadSpriteData(atlas, decodedHash);
        }
    }
예제 #12
0
    /// <summary>
    /// Validate this symbol, given the specified atlas.
    /// </summary>

    public bool Validate(INGUIAtlas atlas)
    {
        if (atlas == null)
        {
            return(false);
        }

#if UNITY_EDITOR
        if (!Application.isPlaying || !mIsValid)
#else
        if (!mIsValid)
#endif
        {
            if (string.IsNullOrEmpty(spriteName))
            {
                return(false);
            }

            Texture tex = null;
            mSprite = atlas.GetSprite(spriteName);

            if (mSprite != null)
            {
                tex = atlas.texture;

                if (tex == null)
                {
                    mSprite = null;
                }
                else
                {
                    mUV      = new Rect(mSprite.x, mSprite.y, mSprite.width, mSprite.height);
                    mUV      = NGUIMath.ConvertToTexCoords(mUV, tex.width, tex.height);
                    mOffsetX = mSprite.paddingLeft;
                    mOffsetY = mSprite.paddingTop;
                    mWidth   = mSprite.width;
                    mHeight  = mSprite.height;
                    mAdvance = mSprite.width + (mSprite.paddingLeft + mSprite.paddingRight);
                    mIsValid = true;
                }
            }
        }
        return(mSprite != null);
    }
예제 #13
0
    /// <summary>
    /// Show the sprite selection wizard.
    /// </summary>

    static public void Show(SerializedObject ob, SerializedProperty pro, INGUIAtlas atlas)
    {
        if (instance != null)
        {
            instance.Close();
            instance = null;
        }

        if (ob != null && pro != null && atlas != null)
        {
            SpriteSelector comp = ScriptableWizard.DisplayWizard <SpriteSelector>("Select a Sprite");
            NGUISettings.atlas          = atlas;
            NGUISettings.selectedSprite = pro.hasMultipleDifferentValues ? null : pro.stringValue;
            comp.mSprite   = null;
            comp.mObject   = ob;
            comp.mProperty = pro;
            comp.mCallback = comp.OnSpriteSelection;
        }
    }