Пример #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));
        }
Пример #2
0
 protected void GoOutput(SWNodeType type, string keyword = "")
 {
     if (ignoreChildOutput)
     {
         return;
     }
     if (!Condition(type))
     {
         return;
     }
     if (receiveOutputTypes.Contains(type))
     {
         SWShaderCreaterBase.CreateProcessorReceiver(type).ProcessOutput(this, keyword);
     }
 }
		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;
		}
Пример #4
0
        private static Shader CreateShader(SWShaderCreaterBase sc)
        {
            foreach (var node in edit.nodes)
            {
                node.shaderOutput = null;
            }

            //step 1: path
            string path = ShaderFilePath(sc.postFix_fileName);

            //step 2: gen shader text
            string txt = sc.CreateShaderText();

            txt = CorrectLineEnding(txt);

            //step 3: create file
            var shader = CreateShaderFile(path, txt);

            return(shader);
        }
 public SWShaderCreaterBase(SWWindowMain _window)
 {
     Instance = this;
     window   = _window;
 }