Fix shader loading, making possible load .shd and .sgp from editor

This commit is contained in:
Franklin Sobrinho 2015-11-27 21:11:20 -03:00
parent ed4738fbed
commit 1138103c63
3 changed files with 19 additions and 19 deletions

View File

@ -535,6 +535,8 @@ void ShaderMaterial::_shader_changed() {
void ShaderMaterial::set_shader(const Ref<Shader>& p_shader) {
ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_MATERIAL);
if (shader.is_valid())
shader->disconnect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
shader=p_shader;

View File

@ -448,31 +448,19 @@ RES ResourceFormatLoaderShader::load(const String &p_path, const String& p_origi
void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("shader");
ObjectTypeDB::get_extensions_for_type("Shader", p_extensions);
}
bool ResourceFormatLoaderShader::handles_type(const String& p_type) const {
return p_type=="Shader";
return ObjectTypeDB::is_type(p_type, "Shader");
}
String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const {
if (p_path.extension().to_lower()=="shader")
if (p_path.extension().to_lower()=="shd")
return "Shader";
return "";
}

View File

@ -89,13 +89,23 @@ void CustomPropertyEditor::_menu_option(int p_which) {
case OBJ_MENU_LOAD: {
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
List<String> extensions;
String type=(hint==PROPERTY_HINT_RESOURCE_TYPE)?hint_text:String();
ResourceLoader::get_recognized_extensions_for_type(type,&extensions);
file->clear_filters();
List<String> extensions;
for (int i=0;i<type.get_slice_count(",");i++) {
ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",",i),&extensions);
}
Set<String> valid_extensions;
for (List<String>::Element *E=extensions.front();E;E=E->next()) {
valid_extensions.insert(E->get());
}
file->clear_filters();
for (Set<String>::Element *E=valid_extensions.front();E;E=E->next()) {
file->add_filter("*."+E->get()+" ; "+E->get().to_upper() );
}