#Some variable stuff, help for poor Sycarium.

1 messages · Page 1 of 1 (latest)

glacial cairn
#

Figuring a branch can be used here.

#

@patent swallow you cant assign a value to the variable, which is a string... but you can get a component from another place where the variable is assigned a string?

#

ultimately, I'll have to get the string new string from a scriptable object.

patent swallow
#

wht are you trying to do exactly

glacial cairn
#

ngh. mm.

patent swallow
#

GetComponent just helps u get to the other script

#

a script becomes a component

glacial cairn
#

yes. which is what I've done.

#

the script name being Task1PrefabVariable ec.

patent swallow
#

you were told already to assign it and actually use it

glacial cairn
#

wait a second.

gray elbow
#

you can't assign to it because it is a read-only property

#

but you can assign it to something else, though that just gets the current value of the string

glacial cairn
#

thank you. I think it should work now.

gray elbow
#

you're not assigning to the variable on Task1PrefabTitleVariable

#

so that isn't doing what you think it is

glacial cairn
#

hmm. you might be right on that. I did need to change the original text copy...

gray elbow
#

i am 100% right on that, it's clear from the code.
at this point you should go through some basic c# courses to get a better idea of how variables/properties/strings/etc work.

glacial cairn
#

tbh, I probably know most of it. but I have forgotten some of it...

glacial cairn
gray elbow
#

because you made it a read-only property.

glacial cairn
#

I've alterered texts before...

gray elbow
#

i'm sure you have. but you created a read-only property instead of just making the variable public

glacial cairn
#

every variable is public here...

#

except the original copy.

#

which is serialized private.

gray elbow
#

hint: properties are not themselves variables. you are exposing the private variable to other objects through a read only property

glacial cairn
#

ah.

gray elbow
#

you cannot assign to the property because as i have explained multiple times now, it is read only.

glacial cairn
#

yes. now I understand.

#

^this is how the "guides" do it.

#

I sort of assumed thats how it worked. but

#

that was wrong of me.

gray elbow
#

you can fix the issue by making the variable public and assign to that directly instead of through the property, or you can give the property both a getter and a setter. i'll let you decide how to accomplish that. i also still recommend some basic c# tutorials

glacial cairn
#

it should be get private set public? or something along those lines

#

my understanding on get set is very limited rn.

#

or private get public set whichever.

#

sadly, tutorials on get set are very bad. :(

#

to show you what I mean...

#

this is what they show ^^'

#

finding how to use {get; private set;} ect. on one line initiations...

#

or...what they would mean. ^^' there's virtually no tutorial for that.

glacial cairn
#

this does a few things. But setting the instance taskparent to the parent set in inspector is not one of them. I think while I used a name for it like newChild it did so, therefore the problem lies in the "instance". Still... another confusion thing is, that it does duplicate it, but not what lies inside "taskprefab". I have the renamed prefab file in there referred, with altered information... but it copies the "prefab" behind that prefab instead. Im unsure how to explain this properly.

#

yesterday, it worked pretty well with, well. the other name. :P but I dont think it'd get the change, cause that's set to this instance variant...