Exemplo n.º 1
0
    CreateSpritePrefab(SsAnimation anime)
    {
        var      po  = new PrefabricatableObject("SpriteStudioPrefabs", anime.name);
        SsSprite spr = po.GetOrAddComponent <SsSprite>();

        spr.Animation = null;           // force to update when the same animation attached
        spr.Animation = anime;
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
        spr.gameObject.SetActive(true);
#endif
        po.Close(true);
    }
Exemplo n.º 2
0
    BuildShaders(string srcPath)
    {
        _shaderPath = Path.GetDirectoryName(srcPath);
        TextAsset ta = AssetDatabase.LoadAssetAtPath(srcPath, typeof(TextAsset)) as TextAsset;

        TextAsset cgShaderTemplateText = AssetDatabase.LoadAssetAtPath(_shaderPath + "/SsCgShaderTemplate.txt", typeof(TextAsset)) as TextAsset;

        // create gameObject as keeper of generated shaders
        var shaderPrefab = new PrefabricatableObject("SpriteStudio/Shaders", "__SsShaderKeeper_DoNotDeleteMe");

        _shaderContainer = shaderPrefab.GetOrAddComponent <SsShaderContainer>();
        if (!_shaderContainer)
        {
            Debug.LogError("Fatal error!!: cannot create shader keeper. try to reimport all.");
            return;
        }

        // to be invisible
        _shaderContainer.gameObject.hideFlags = HideFlags.NotEditable;        //|HideFlags.HideInHierarchy;
        // clear shader list
        _shaderContainer._shaders.Clear();

        // create all the variations
        foreach (var ce in _colorBlends)
        {
            foreach (var ae in _alphaBlends)
            {
                foreach (var mce in _materialColorBlends)
                {
                    BuildShader(ta.text, ce.name == "NonColor" ? "" : cgShaderTemplateText.text, ce, ae, mce);
                }
            }
        }

#if _BUILD_UNIFIED_SHADERS
        // create color blend unified shaders
        {
            string unifiedSrcPath = srcPath;
            unifiedSrcPath = unifiedSrcPath.Replace(_shaderTemplateFilename, "SsUnifiedShaderTemplate.txt");
            _shaderPath    = Path.GetDirectoryName(unifiedSrcPath);
            ta             = AssetDatabase.LoadAssetAtPath(unifiedSrcPath, typeof(TextAsset)) as TextAsset;

            foreach (var ae in _alphaBlends)
            {
                BuildUnifiedShader(ta.text, ae);
            }
        }
#endif
        shaderPrefab.Close(true);
    }