Exemplo n.º 1
0
        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 AfterLoad()
        {
            if (!string.IsNullOrEmpty(data.textureGUID))
            {
                texture = SWEditorTools.GUIDToObject <Texture2D>(data.textureGUID);
            }
            if (!string.IsNullOrEmpty(data.textureGUIDGray))
            {
                textureGray = SWEditorTools.GUIDToObject <Texture2D>(data.textureGUIDGray);
            }
            if (!string.IsNullOrEmpty(data.textureExGUID))
            {
                var tex = SWEditorTools.GUIDToObject <Texture2D>(data.textureExGUID);
                textureEx = new SWTexture2DEx(tex);
            }

            if (!string.IsNullOrEmpty(data.spriteGUID))
            {
                string   path = AssetDatabase.GUIDToAssetPath(data.spriteGUID);
                Object[] objs = AssetDatabase.LoadAllAssetsAtPath(path);
                foreach (var item in objs)
                {
                    if (item is Sprite && item.name == data.spriteName)
                    {
                        //Debug.Log ("Found");
                        sprite = (Sprite)item;
                    }
                }
            }
        }
        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);
            }
        }
Exemplo n.º 4
0
 public override void DrawMainBot()
 {
     base.DrawMainBot();
     if (brightBackground)
     {
         SWEditorTools.DrawTiledTexture(al_rectMain, SWEditorTools.backdropTextureBright);
     }
     else
     {
         SWEditorTools.DrawTiledTexture(al_rectMain, SWEditorTools.backdropTexture);
     }
 }
        protected override void DrawLeftRect(int id, Rect rect)
        {
            UpdatePort();
            rect = new Rect(rect.x, rect.y, rect.width, rect.height);
            SWEditorTools.DrawTiledTexture(rect, SWEditorTools.backdropTexture);
            GUI.DrawTexture(rect, data.gradients[id].Tex);



            if (SWCommon.GetMouseUp(1) && rect.Contains(Event.current.mousePosition))
            {
                SWWindowMixerEditor.Show(data.gradients [id]);
            }
        }
		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;
		}
Exemplo n.º 7
0
 protected override void DrawLeftRect(int id, Rect rect)
 {
     if (id == 0)
     {
         base.DrawLeftRect(id, rect);
     }
     else
     {
         UpdatePort();
         SWEditorTools.DrawTiledTexture(rect, SWEditorTools.backdropTexture);
         GUI.DrawTexture(rect, data.gradients [id - 1].Tex);
         if (window.InMapClick(0) && rect.Contains(window.mousePosLast))
         {
             SWWindowMixerEditor.Show(data.gradients [id - 1]);
         }
     }
 }
Exemplo n.º 8
0
        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 = "";
            }
        }
Exemplo n.º 9
0
 public override void DrawMainBot()
 {
     base.DrawMainBot();
     SWEditorTools.DrawTiledTexture(al_rectMain, SWEditorTools.backdropTexture);
 }
Exemplo n.º 10
0
        void OnGUI()
        {
            baseRect  = new Rect(Gap, Gap, position.width - Gap * 2, 20);
            texRect   = new Rect(Gap, baseRect.yMax, position.width - Gap * 2, 50);
            timeRect  = new Rect(Gap, texRect.yMax + Gap, position.width - Gap * 2, 20);
            valueRect = new Rect(Gap, timeRect.yMax, position.width - Gap * 2, 20);

            if (SWCommon.GetMouseDown(1))
            {
                if (!baseRect.Contains(Event.current.mousePosition))
                {
                    mode   = SWGradientMode.no;
                    opItem = null;
                }
            }

            if (SWCommon.GetMouseDown(0))
            {
                bool doit = false;
                if (mode == SWGradientMode.no)
                {
                    for (int i = 0; i < gradient.frames.Count; i++)
                    {
                        var  item = gradient.frames [i];
                        Rect rect = CalRect(item);
                        if (rect.Contains(Event.current.mousePosition))
                        {
                            doit   = true;
                            mode   = SWGradientMode.select;
                            opItem = item;
                        }
                    }
                }
                else if (mode == SWGradientMode.select)
                {
                    for (int i = 0; i < gradient.frames.Count; i++)
                    {
                        var  item = gradient.frames [i];
                        Rect rect = CalRect(item);
                        if (rect.Contains(Event.current.mousePosition))
                        {
                            doit   = true;
                            opItem = item;
                            if (opItem == item)
                            {
                                mode = SWGradientMode.move;
                            }
                        }
                    }
                }
                else if (mode == SWGradientMode.move)
                {
                    doit        = true;
                    opItem.time = TimeOnPos();
                }

                if (!doit)
                {
                    if (baseRect.Contains(Event.current.mousePosition))
                    {
                        var item = new SWGradientFrame();
                        item.time = TimeOnPos();
                        gradient.frames.Add(item);
                        mode   = SWGradientMode.select;
                        opItem = item;
                    }
                }
            }
            if (SWCommon.GetMouse(0))
            {
                if (mode == SWGradientMode.no)
                {
                }
                else if (mode == SWGradientMode.select)
                {
                }
                else if (mode == SWGradientMode.move)
                {
                    opItem.time = TimeOnPos();
                }
            }
            if (SWCommon.GetMouseUp(0))
            {
                if (mode == SWGradientMode.no)
                {
                }
                else if (mode == SWGradientMode.select)
                {
                }
                else if (mode == SWGradientMode.move)
                {
                    mode = SWGradientMode.select;
                }
            }
            if (Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == KeyCode.Delete)
                {
                    if (mode == SWGradientMode.select && opItem != null)
                    {
                        gradient.frames.Remove(opItem);
                    }
                }
            }


            gradient.Sort();
            GUI.color = Color.black;
            GUI.DrawTexture(baseRect, SWEditorTools.blankTexture);
            GUI.color = Color.white;

            SWEditorTools.DrawTiledTexture(texRect, SWEditorTools.backdropTexture);
            GUI.DrawTexture(texRect, gradient.Tex);
            bool uppperEvent = false;

            for (int i = 0; i < gradient.frames.Count; i++)
            {
                var  item = gradient.frames [i];
                Rect rect = CalRect(item);
                GUI.DrawTexture(rect, icon);
                if (opItem == item)
                {
                    GUI.DrawTexture(rect, iconSelect);
                }
            }

            if (opItem != null)
            {
                opItem.time  = EditorGUI.Slider(timeRect, "Position:", opItem.time, 0, 1);
                opItem.value = EditorGUI.Slider(valueRect, "Value:", opItem.value, 0, 1);
            }
        }