Ejemplo n.º 1
0
        private static Shader CreateStep_Shader()
        {
            SWShaderCreaterBase sc = null;

            if (edit.data.shaderType == SWShaderType.normal)
            {
                sc = new SWShaderCreaterBase(edit);
            }
            else if (edit.data.shaderType == SWShaderType.ui)
            {
                sc = new SWShaderCreaterUI(edit);
            }
            else if (edit.data.shaderType == SWShaderType.uiFont)
            {
                sc = new SWShaderCreaterUIFont(edit);
            }
            else 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);
                }
            }
            else if (edit.data.shaderType == SWShaderType.ngui_ui2dSprite)
            {
                sc = new SWShaderCreaterNGUI(edit);
            }
            return(CreateShader(sc));
        }
		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;
		}