Announcements
The Scaleform forum is now read-only. Please head to the Gamedev site for product support.
Scaleform Forum (Read Only)
Scaleform enables developers to leverage the power of the Adobe® Flash® tool set to create powerful user interface environments for video games.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom ListItemRender with DataProvider

0 REPLIES 0
Reply
Message 1 of 1
Doobyman
270 Views, 0 Replies

Custom ListItemRender with DataProvider

Hi there,

 

I seem to be really lost. I am trying to create a custom ListItemRenderer for my scrolling list. The MovieClip contains textField, and also a Paint movieclip which is a white block that I need to tint with provided floats.

 

Okay so, in Unity I want to grab the paint name and my four floats for the color (rgba) and store them in an object, then add that object to the dataprovider, whereby I assume the setData function on my custom ListItemRender is automatically run and can do its business.

 

1. How do I create the object I need in Unity first? I've seen https://forums.epicgames.com/threads/844239-Displaying-an-Icon-in-a-Scrolling-List (which is almost exactly what I want to do, except I'm passing four floats for color instead of the path to an image) but it isn't really helping me much.

I've also seen http://forums.autodesk.com/t5/Scaleform-Unity-Development/ANSWERED-Commit-an-array-to-Flash/td-p/426... but am unsure how it works in relation to the dataProvider and ListItemRenderer. 

If I was creating an ordinary plain text list i would just push a string to the end of the dataProvider, which would automatically be put in the correct place. But doing the above I'm not sure how to access the data at the other end. Which takes me to:

 

2. In the setData function on my custom ListItemRenderer, it takes in an object. This is presumably the Value array that I created in Unity and passed to the dataProvider. But how do I get the data out again? I've tried accessing it like a normal array (so in my case it would be a 5 count array, first element is the color name and the other four are my color floats) but it doesn't seem to like it. I also get an error from the DropdownMenu in itemToLabel, claiming "Property label not found on 0 and there is no default value".

 

Here is my code:

 

C#:

public void Customize_AddPaintToPaintSelector( string paintName, Color color )
{
  double red = (double)color.r;
  double green = (double)color.g;
  double blue = (double)color.b;
  double alpha = (double)color.a;

 

  Value[] paintData = new Value[5];
  paintData[0] = new Value( paintName, this.MovieID );
  paintData[1] = new Value( red, this.MovieID );
  paintData[2] = new Value( green, this.MovieID );
  paintData[3] = new Value( blue, this.MovieID );
  paintData[4] = new Value( alpha, this.MovieID );

 

 //dataprovider

  Value selectorData = Garage_Customize_PaintsPanel.GetMember( "paintSelectorData" ); 

  selectorData.PushBack( paintData );

}

 

Flash:

public class Customize_PaintSelectorItemRenderer extends ListItemRenderer {

public var paint:MovieClip;

public var paintName:String;
public var colorR:Number;
public var colorG:Number;
public var colorB:Number;
public var colorA:Number;

public function Customize_PaintSelectorItemRenderer() {
  super();
}

override public function setData( data:Object ) : void {
  this.data = data;

  paintName = data[0] as String;
  colorR = data[1] as Number;
  colorG = data[2] as Number;
  colorB = data[3] as Number;
  colorA = data[4] as Number;

  textField.text = paintName;

  var colorPartColor:ColorTransform = new ColorTransform( colorR, colorG, colorB, 1, 0, 0, 0, 0 );
  paint.square.transform.colorTransform = colorPartColor;

  paint.shiny.alpha = colorA;
}
}

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report