示例#1
0
    public virtual SeinJS.SeinNodeOption SerializeValue(SeinJS.ExporterEntry entry, SeinAtlas option)
    {
        ExtensionManager.Serialize(ExtensionManager.GetExtensionName(typeof(Sein_atlasExtensionFactory)), entry, entry.root.Extensions, option);
        var atlasId = Sein_atlasExtensionFactory.GetAtlasIndex(entry, option);

        return(new SeinJS.SeinNodeOption("Atlas", new JObject(new JProperty("index", atlasId))));
    }
    private void DoImport(SeinAtlas atlas)
    {
        var fp = EditorUtility.OpenFilePanel("Choose atlas file", "", "atlas,json");

        if (fp == "")
        {
        }
        else
        {
            atlas.Import(fp);
        }
    }
    public override void OnInspectorGUI()
    {
        SeinAtlas atlas = (SeinAtlas)target;

        serializedObject.Update();

        EditorGUILayout.PropertyField(serializedObject.FindProperty("maxWidth"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("maxHeight"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("padding"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("isImageCanRelease"));

        var option = EEditorListOption.ListLabel | EEditorListOption.Buttons;

        EditorList.Show(serializedObject.FindProperty("images"), option);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("saveAfterPack"));
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Pack", GUILayout.Width(80), GUILayout.Height(40)))
        {
            atlas.Pack();
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Save", GUILayout.Width(80), GUILayout.Height(40)))
        {
            atlas.Save();
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Import", GUILayout.Width(80), GUILayout.Height(40)))
        {
            if (atlas != null && atlas.images != null && atlas.images.Length != 0)
            {
                if (EditorUtility.DisplayDialog(
                        "This atlas is not empty",
                        "New atlas will overwrite it !",
                        "Continue",
                        "Cancel"
                        ))
                {
                    DoImport(atlas);
                }
            }
            else
            {
                DoImport(atlas);
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.Label("Final Atlas");
        GUILayout.Label(atlas.atlasTexture);

        serializedObject.ApplyModifiedProperties();
    }
    public void OnValidate()
    {
        if (!GetComponent <MeshFilter>())
        {
            return;
        }

        if (_preMat != material)
        {
            gameObject.GetComponent <MeshRenderer>().sharedMaterial = material;
        }

        if (_preAtlas != atlas || _preFrameName != frameName)
        {
            if (material)
            {
                SetFrame(atlas, frameName);
            }
        }

        _preAtlas     = atlas;
        _preFrameName = frameName;
    }
示例#5
0
 public static int GetAtlasIndex(ExporterEntry entry, SeinAtlas atlas)
 {
     return(ENTRY_ATLASES[entry].IndexOf(atlas));
 }
    public void SetFrame(SeinAtlas atlas, string frameName)
    {
        var tex = atlas.Get(frameName);

        material.SetTexture("_MainTex", tex);
    }