Adam's Lair Forum

game development and casual madness
It is currently 2020/03/29, 13:40

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 2014/03/24, 21:15 
Member
Member
User avatar

Joined: 2014/01/25, 21:14
Posts: 52
Role: Hobbyist
I have variables that would require some variables to have more than 2 decimals, but the editor does not allow that for some reason. For example, I want to have 0.001 as a value, but it removes the last number and makes 0.00 out of it.

I don't know if this is intended behavior, but yeah...


Top
 Profile  
 
PostPosted: 2014/03/24, 21:25 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
Hi Ekibyou, if you are talking about floats or doubles, you can try with this

Code:
[EditorHintDecimalPlaces(1)]
public float Property
{
   get { return _field; }
   set { _field = value; }
}


With Vectors and so on, I think it's fixed..

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2014/03/24, 21:28 
Member
Member
User avatar

Joined: 2014/01/25, 21:14
Posts: 52
Role: Hobbyist
SirePi wrote:
Hi Ekibyou, if you are talking about floats or doubles, you can try with this

Code:
[EditorHintDecimalPlaces(1)]
public float Property
{
   get { return _field; }
   set { _field = value; }
}


With Vectors and so on, I think it's fixed..


I use floats now, so that's the problem :).
I think the same happens in Vector2's.


Top
 Profile  
 
PostPosted: 2014/03/24, 21:30 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
Ekibyou wrote:
I use floats now, so that's the problem :).
I think the same happens in Vector2's.


Yes, I meant.. that code works with floats, but it won't with Vector2.

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2014/03/24, 21:38 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
SirePi wrote:
Hi Ekibyou, if you are talking about floats or doubles, you can try with this

Code:
[EditorHintDecimalPlaces(1)]
public float Property
{
   get { return _field; }
   set { _field = value; }
}


This is the correct answer. EditorHintDecimalPlaces will work with float, double and all kinds of Vectors. However, if you want to express 0.001, you should set this to 3 instead of 1. For added convenience, you might also want to add EditorHintIncrement with 0.001f as a parameter.

Additional Note: This feature was broken for a while, and I'm not sure whether there was a new binary release since I've fixed it, so you're probably just using a Duality version where this doesn't work. You can use the GitHub version for an immediate fix, or wait until the next binary release, which may take 1-2 weeks.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2014/03/24, 21:40 
Member
Member
User avatar

Joined: 2014/01/25, 21:14
Posts: 52
Role: Hobbyist
Oh, right!
I didn't see the thing you added on top there!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group