Ejemplo n.º 1
0
 static public bool CheckIfRelated(MeshSpriteMaker a, MeshSpriteMaker b)
 {
     if (a == null || b == null)
     {
         return(false);
     }
     return(a == b || a.References(b) || b.References(a));
 }
Ejemplo n.º 2
0
 bool References(MeshSpriteMaker atlas)
 {
     if (atlas == null)
     {
         return(false);
     }
     if (atlas == this)
     {
         return(true);
     }
     return(false);
 }
    void MarkSpriteAsDirty()
    {
        var meshspritemaker = target as MeshSpriteMaker;

        MeshSprite[] sprites = CWALKEditorTools.FindActive <MeshSprite>();

        foreach (MeshSprite ms in sprites)
        {
            if (MeshSpriteMaker.CheckIfRelated(ms.meshSpriteMaker, meshspritemaker))
            {
                ms.UpdateMesh();
                EditorUtility.SetDirty(ms);
            }
        }
    }
Ejemplo n.º 4
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        GUILayout.Space(6f);
        var meshsprite = target as MeshSprite;

        if (meshsprite != null)
        {
            s_meshSpriteMaker = meshsprite.meshSpriteMaker;

            CWALKEditorTools.BeginContents();
            CWALKEditorTools.RegisterUndo("Sprite Change", meshsprite);
            MeshSpriteMaker SpriteAssemble = EditorGUILayout.ObjectField("Mesh Sprite Maker:", s_meshSpriteMaker, typeof(MeshSpriteMaker), false) as MeshSpriteMaker;

            if (SpriteAssemble == null)
            {
                meshsprite.meshSpriteMaker = null;
                Color tempBgcolor = GUI.backgroundColor;
                GUI.backgroundColor = Color.red;
                EditorGUILayout.HelpBox("No MeshSpriteMaker file found,Please Check On", MessageType.Warning);
                GUI.backgroundColor = tempBgcolor;
                return;
            }
            else
            {
                if (SpriteAssemble != meshsprite.meshSpriteMaker)
                {
                    meshsprite.meshSpriteMaker = SpriteAssemble;
                }
            }

            if (meshsprite.material == null)
            {
                GUILayout.Space(6f);
                Color tempBgcolor = GUI.backgroundColor;
                GUI.backgroundColor = Color.red;
                EditorGUILayout.HelpBox("No Material On Render", MessageType.Warning);
                GUI.backgroundColor = tempBgcolor;
                return;
            }
            else
            {
                if (meshsprite.material.mainTexture == null)
                {
                    meshsprite.selectDefaultTex();
                }
            }

            CWALKEditorTools.RegisterUndo("Sprite Change", meshsprite);
            GUILayout.BeginHorizontal();
            if (CWALKEditorTools.DrawPrefixButton("Mesh Sprite"))
            {
                CWALKSettingTools.S_MeshSpriteMaker = meshsprite.meshSpriteMaker;
                if (meshsprite.mainTexture != null)
                {
                    CWALKSettingTools.S_SelectedSprite = meshsprite.mainTexture.name;
                }
                MeshSpriteSelector.Show(OnSelectAtlas);
            }

            GUILayout.Space(14f);
            if (meshsprite.mainTexture != null)
            {
                GUILayout.Label(meshsprite.mainTexture.name, "helpbox");
            }
            else
            {
                Color tempBgcolor = GUI.backgroundColor;
                GUI.backgroundColor = Color.red;
                GUILayout.Label("material texture is null", "helpbox");
                GUI.backgroundColor = tempBgcolor;
                //
            }

            GUILayout.EndHorizontal();

            //MeshSpriteMode meshmode = (MeshSpriteMode) EditorGUILayout.EnumPopup("Mesh Mode :", meshsprite.meshMode);
            CWALKEditorTools.RegisterUndo("Sprite Change", meshsprite);
            Color tempBgColor = GUI.backgroundColor;

            GUI.backgroundColor = Color.green;
            GUILayout.Space(5f);
            MeshSpriteMode meshmode = (MeshSpriteMode)EditorGUILayout.EnumPopup("Mesh Mode:", meshsprite.meshMode);
            GUILayout.Space(5f);
            CWALKEditorTools.RegisterUndo("Sprite Change", meshsprite);
            float spritewidth = EditorGUILayout.FloatField("Sprite Width:", meshsprite.Width);
            spritewidth = Mathf.Clamp(spritewidth, 1f, 1000f);

            float spriteheight = EditorGUILayout.FloatField("Sprite Height:", meshsprite.Height);
            spriteheight = Mathf.Clamp(spriteheight, 1f, 1000f);

            if (GUI.changed)
            {
                meshsprite.Width    = spritewidth;
                meshsprite.Height   = spriteheight;
                meshsprite.meshMode = meshmode;
                //		meshsprite.borderColor = _borderColor;
                EditorUtility.SetDirty(meshsprite);
            }

            GUI.backgroundColor = tempBgColor;
            CWALKEditorTools.EndContents();
        }
    }