playMaker

Author Topic: changing alpha channel of a non gui texture  (Read 10040 times)

gamedivision

  • Full Member
  • ***
  • Posts: 227
changing alpha channel of a non gui texture
« on: May 23, 2012, 06:35:24 PM »
ive created 2 buttons on screen,made from a simple plane then added the texture to that plane,now how would i change the transparency of that image,
i see in the color menu you have,set color rgba,then adding a color variable,but that doesnt change it
any ideas,what im looking for is a transparent button once pressed goes to full color,i cant use gui texture because that cant be batched to reduce draw calls,ive also setup an orthographic camera to render the buttons


thanks

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: changing alpha channel of a non gui texture
« Reply #1 on: May 23, 2012, 06:39:24 PM »
Make sure your material supports transparency. E.g. Transparent/Diffuse.

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: changing alpha channel of a non gui texture
« Reply #2 on: May 23, 2012, 06:41:46 PM »
it is
mobile transparent

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: changing alpha channel of a non gui texture
« Reply #3 on: May 23, 2012, 06:45:50 PM »
would it be the fact that its an image with transparency on a plane or not

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: changing alpha channel of a non gui texture
« Reply #4 on: May 23, 2012, 06:54:21 PM »
Does the image have an alpha channel?

I haven't played with mobile transparent much, but I would try to get it working with the Unity inspectors then try to reproduce in Playmaker...

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: changing alpha channel of a non gui texture
« Reply #5 on: May 23, 2012, 06:59:45 PM »
yeah i tried unity transparent diffuse,nothing
so i should be able to use set color rgba,in an fsm an it should change the transparency right

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: changing alpha channel of a non gui texture
« Reply #6 on: May 24, 2012, 01:42:21 AM »
Hi,

 I ran a test few days ago for another thread and indeed setting the color within fsm for a material does work for the alpha channel. the material must of course be of type transparent.

 Bye,

 Jean

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: changing alpha channel of a non gui texture
« Reply #7 on: May 24, 2012, 07:55:35 AM »
ok ive found what changes the color and alpha channel,
set material color,
i created a listener state with a get mouse down and a set material color with alpha at half way,
then a touched state with set material color with alpha on full and a finish event so it travels back to the listener.
unless the transition is so quick it doesnt recognise it,but it doesnt change,it only changes when i remove the finish event and it stays on the touched state.
is there a way to delay the return transition by half a second so i can see the alpha change


thanks

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: changing alpha channel of a non gui texture
« Reply #8 on: May 24, 2012, 09:23:35 AM »
i found a solution
start state,has get mouse down(just for test purpose)set material color,with a touched send event,
on the touched state i have  a set material color and a color interpolate, also added a finish state.
so i now have a loopable button effecting the alpha channel only.

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: changing alpha channel of a non gui texture
« Reply #9 on: May 24, 2012, 09:45:09 AM »
the final solution i came up with
listener state with a touched event,
1,set material color
2,touch object event
3,get mouse button down
i have 1 for testing on mobile and one for quick testing on computer
then once it receives the touch or mouse button down,if flies into the touched state where i have
1,set material color
2,touch object event
3,get mouse button up
here i have a release event,so if touch ended or touch cancelled then flows into the released event which goes back to the listener,same with the mouse button up flies into the released event
one problem solved.
haha ;D

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Re: changing alpha channel of a non gui texture
« Reply #10 on: May 24, 2012, 10:45:16 AM »
Is there a special setting you have to click in the import settings of an image to support transparency?  Or is there an option for this when you make the material itself?  The inspector always shows the images weird for me, but then in the game they look normal and have transparency.  Then when I try to use iTween it doesn't seem to be altering the transparency.
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: changing alpha channel of a non gui texture
« Reply #11 on: May 24, 2012, 04:06:10 PM »
no special setting,i just export my 2d image as a png 24 then drag and drop into unity override for iphone,mobile transparent vertex color.

gamedivision

  • Full Member
  • ***
  • Posts: 227
Re: changing alpha channel of a non gui texture
« Reply #12 on: May 26, 2012, 06:51:45 AM »
just another question on this,using a simple plane for a button instead of a gui texture would i need to add a collider to that and set  the pick distance on the touch object event,