x


more Burgzerg Blues

Unity is having trouble with one script, both of these seem to be doing the same thing, but I'm not sure which one needs to go.

public struct ModifyingAttribute
{
    public Attribute attribute;
    public float ratio;
}

public ModifyingAttribute(Attribute att, float rat)
{
    Debug.Log("Modifying Attribute Created.");
    attribute=att;
    ratio= rat;
}

The debug command cannot exist is a struct. Which one needs to stay and why? Thanks!

more ▼

asked Mar 08 '12 at 07:17 PM

Gilead7 gravatar image

Gilead7
117 32 41 48

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

public ModifyingAttribute(...) is a constructor and needs to be declared and implemented inside the struct scope.

more ▼

answered Mar 09 '12 at 06:49 AM

Berenger gravatar image

Berenger
12.4k 15 21 63

I don't understand... Please explain and forgive my newbieness.

Mar 09 '12 at 04:44 PM Gilead7

That's what you need to do :

public struct ModifyingAttribute
{
    public Attribute attribute;
    public float ratio;
    public ModifyingAttribute(){}
    public ModifyingAttribute(Attribute att, float rat)
    {
        Debug.Log("Modifying Attribute Created.");
        attribute=att;
        ratio= rat;
    }
}
Mar 09 '12 at 05:22 PM Berenger
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x7661
x514
x64

asked: Mar 08 '12 at 07:17 PM

Seen: 607 times

Last Updated: Mar 09 '12 at 05:23 PM