//----------------------------------------------------------------------------

    private void ReloadConstants(bool flush)
    {
        serializedObject.Update();
        PkFxCustomShader customShader = (serializedObject.targetObject as PkFxCustomShader);

        int count = -1;

        if (customShader.m_Api == PkFxCustomShader.EShaderApi.GL && !m_InShaderConstantsLoading)
        {
            PKFxManager.ShaderConstantsCount(customShader.m_ShaderName, (int)customShader.m_Api);
            GL.IssuePluginEvent(PKFxManager.GetGLConstantsCountEvent(), (int)(PKFxManager.POPCORN_MAGIC_NUMBER | 0x00004000));
            m_InShaderConstantsLoading = true;
        }
        else
        {
            count = PKFxManager.ShaderConstantsCount(customShader.m_ShaderName, (int)customShader.m_Api);
        }

        if (count != -1)
        {
            m_InShaderConstantsLoading = false;
            List <PKFxManager.ShaderConstantDesc> FxAttributesDesc = PKFxManager.ListShaderConstantsFromName(customShader.m_ShaderName, count);
            customShader.LoadShaderConstants(FxAttributesDesc, flush);
            EditorUtility.SetDirty(target as PkFxCustomShader);
            AssetDatabase.SaveAssets();
            serializedObject.ApplyModifiedProperties();
            serializedObject.Update();
        }
    }