예제 #1
0
    AddShaderKeeperToCurrentScene()
    {
#if _ADD_SHADER_KEEPER
        // we don't check exsiting because it needs that we create prefab and exit this function once then import it and get instance of it!!
//		if (PrefabricatableObject.Exists("SpriteStudioPrefabs", "__SsShaderKeeper_DoNotDeleteMe"))
//			BuildShaders();
        //Object obj = FindObjectOfType(typeof(SsShaderContainer));

        //SsTimer.StartTimer();
        GameObject obj = GameObject.Find("__SsShaderKeeper_DoNotDeleteMe");
        //SsTimer.EndTimer("finding shader keeper");
        if (obj)
        {
            if (PrefabUtility.GetPrefabType(obj) == PrefabType.MissingPrefabInstance)
            {
                // missing, so delete it then restore
                GameObject.DestroyImmediate(obj);
            }
            else
            {
                return;
            }
        }

        //SsTimer.StartTimer();
        GameObject go = PrefabricatableObject.LoadPrefab("SpriteStudio/Shaders", "__SsShaderKeeper_DoNotDeleteMe");
        EditorUtility.InstantiatePrefab(go);
        //SsTimer.EndTimer("instantiating shader keeper");
#endif
    }
예제 #2
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);
    }
예제 #3
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);
    }