private static Material CreateStep_Material(Shader shader) { string path = ""; if (edit.newCopy || string.IsNullOrEmpty(edit.data.materialGUID) || string.IsNullOrEmpty(AssetDatabase.GUIDToAssetPath(edit.data.materialGUID))) { path = string.Format("{0}{1}.mat", edit.folderPath, edit.data.title); } else { path = SWCommon.AssetDBPath2Path(AssetDatabase.GUIDToAssetPath(edit.data.materialGUID)); } Material m = AssetDatabase.LoadAssetAtPath <Material> (SWCommon.Path2AssetDBPath(path)); if (m == null) { m = new Material(shader); SetMaterialProp(m, edit); m = SWCommon.SaveReload <Material> (m, path); } else { m.shader = shader; SetMaterialProp(m, edit); } edit.data.materialGUID = SWEditorTools.ObjectToGUID(m); return(m); }
public virtual void BeforeSave() { if (texture != null) { data.textureGUID = SWEditorTools.ObjectToGUID(texture); } else { data.textureGUID = ""; } if (textureGray != null) { data.textureGUIDGray = SWEditorTools.ObjectToGUID(textureGray); } else { data.textureGUIDGray = ""; } if (!textureEx.IsNull) { data.textureExGUID = SWEditorTools.ObjectToGUID(textureEx); } else { data.textureExGUID = ""; } if (sprite != null) { data.spriteName = sprite.name; data.spriteGUID = SWEditorTools.ObjectToGUID(sprite); } }
public static Material CreateMaterial(SWWindowMain edit) { foreach (var item in edit.NodeAll()) { item.Value.shaderOutput = null; } SWShaderCreaterBase sc = null; if (edit.data.shaderType == SWShaderType.normal) { sc = new SWShaderCreaterBase (edit); } if (edit.data.shaderType == SWShaderType.ui) { sc = new SWShaderCreaterUI (edit); } if (edit.data.shaderType == SWShaderType.uiFont) { sc = new SWShaderCreaterUIFont (edit); } if (edit.data.shaderType == SWShaderType.sprite) { if(edit.data.spriteLightType == SWSpriteLightType.no) sc = new SWShaderCreaterSprite (edit); else if(edit.data.spriteLightType == SWSpriteLightType.diffuse) sc = new SWShaderCreaterSpriteLight (edit); } float f = Time.realtimeSinceStartup; string txt = sc.CreateShaderText(); var shader = CreateShader (edit,txt); string path = ""; if (edit.newCopy || string.IsNullOrEmpty (edit.data.materialGUID)) path = string.Format ("{0}{1}.mat", edit.folderPath, edit.data.title); else path = SWCommon.AssetDBPath2Path(AssetDatabase.GUIDToAssetPath (edit.data.materialGUID)); Material m = AssetDatabase.LoadAssetAtPath<Material> (SWCommon.Path2AssetDBPath(path)); if (m == null) { m = new Material (shader); SetMaterialProp (m, edit); m = SWCommon.SaveReload<Material> (m, path); } else { m.shader = shader; SetMaterialProp (m, edit); } edit.data.materialGUID = SWEditorTools.ObjectToGUID (m); return m; }
public virtual void BeforeSave() { if (texture != null) { data.textureGUID = SWEditorTools.ObjectToGUID(texture); } else { data.textureGUID = ""; } if (textureGray != null) { data.textureGUIDGray = SWEditorTools.ObjectToGUID(textureGray); } else { data.textureGUIDGray = ""; } if (!textureEx.IsNull) { data.textureExGUID = SWEditorTools.ObjectToGUID(textureEx); } else { data.textureExGUID = ""; } if (sprite != null) { data.spriteName = sprite.name; data.spriteGUID = SWEditorTools.ObjectToGUID(sprite); } //Sprite Light Normal mapping if (textureNormalMap != null) { data.nmid = SWEditorTools.ObjectToGUID(textureNormalMap); } else { data.nmid = ""; } }