variable not updating on other script2019 Community Moderator ElectionHow do I update the GUI from another thread?Is there a reason for C#'s reuse of the variable in a foreach?Entity Framework 5 Updating a RecordHow to check for null in this specific situationBasic Architecture / Handling many GameObjects with different update strategiesChecking Animator on Unity script only work on first ObjectUnity game - Only assignment, call, increment, decrement, await, and new object expressions can be used as a statementGameObject activates too soonPrefab clone does not have script component attachedReading from file more efficient than GameObject.Find?
How to educate team mate to take screenshots for bugs with out unwanted stuff
Does the US political system, in principle, allow for a no-party system?
What do you call someone who likes to pick fights?
Can I negotiate a patent idea for a raise, under French law?
Mixed Feelings - What am I
How can I have x-axis ticks that show ticks scaled in powers of ten?
Generating a list with duplicate entries
Boss Telling direct supervisor I snitched
Professor forcing me to attend a conference, I can't afford even with 50% funding
Is it a Cyclops number? "Nobody" knows!
Who has more? Ireland or Iceland?
Did Amazon pay $0 in taxes last year?
What is the oldest European royal house?
How spaceships determine each other's mass in space?
3.5% Interest Student Loan or use all of my savings on Tuition?
Why isn't P and P/poly trivially the same?
ESPP--any reason not to go all in?
What would be the most expensive material to an intergalactic society?
Is divide-by-zero a security vulnerability?
Propulsion Systems
direct sum of representation of product groups
PTIJ: Sport in the Torah
Inorganic chemistry handbook with reaction lists
What is the orbit and expected lifetime of Crew Dragon trunk?
variable not updating on other script
2019 Community Moderator ElectionHow do I update the GUI from another thread?Is there a reason for C#'s reuse of the variable in a foreach?Entity Framework 5 Updating a RecordHow to check for null in this specific situationBasic Architecture / Handling many GameObjects with different update strategiesChecking Animator on Unity script only work on first ObjectUnity game - Only assignment, call, increment, decrement, await, and new object expressions can be used as a statementGameObject activates too soonPrefab clone does not have script component attachedReading from file more efficient than GameObject.Find?
So this is in line with another question i asked but im taking a different route. The question i have is in this script i am finding the level of the player from the LevelManager script. Im going to use a different panel for each player level and make them active as the level increases. Not the best way i understand. The problem i am having is that level in this script is not updating with currentLevel in my other script so the panels are not turning on because the level is always 0. Any help is appreciated. Neil
public GameObject Panel1;
public GameObject Panel2;
public GameObject Panel3;
public GameObject levelscript;
public int level;
public void Start()
GameObject scoreEventTrigger = GameObject.Find("ScoreEventTrigger");
LevelManager levelManager = scoreEventTrigger.GetComponent<LevelManager>();
level = levelManager.currentLevel;
public void OpenPanel1()
if (level == 1)
if (Panel1 != null)
Panel1.SetActive(true);
public void OpenPanel2()
if (level == 2)
if (Panel2 != null)
Panel2.SetActive(true);
}
c# user-interface unity3d
New contributor
add a comment |
So this is in line with another question i asked but im taking a different route. The question i have is in this script i am finding the level of the player from the LevelManager script. Im going to use a different panel for each player level and make them active as the level increases. Not the best way i understand. The problem i am having is that level in this script is not updating with currentLevel in my other script so the panels are not turning on because the level is always 0. Any help is appreciated. Neil
public GameObject Panel1;
public GameObject Panel2;
public GameObject Panel3;
public GameObject levelscript;
public int level;
public void Start()
GameObject scoreEventTrigger = GameObject.Find("ScoreEventTrigger");
LevelManager levelManager = scoreEventTrigger.GetComponent<LevelManager>();
level = levelManager.currentLevel;
public void OpenPanel1()
if (level == 1)
if (Panel1 != null)
Panel1.SetActive(true);
public void OpenPanel2()
if (level == 2)
if (Panel2 != null)
Panel2.SetActive(true);
}
c# user-interface unity3d
New contributor
This looks okay to me. Are you sure you are correctly adjustingcurrentLevel
inLevelManager
?
– Ali Kanat
2 days ago
Thanks for replying @AliKanat. Yup the score adjusts perfectly in the game. Just not on the button this script is attached to.
– Neil
2 days ago
add a comment |
So this is in line with another question i asked but im taking a different route. The question i have is in this script i am finding the level of the player from the LevelManager script. Im going to use a different panel for each player level and make them active as the level increases. Not the best way i understand. The problem i am having is that level in this script is not updating with currentLevel in my other script so the panels are not turning on because the level is always 0. Any help is appreciated. Neil
public GameObject Panel1;
public GameObject Panel2;
public GameObject Panel3;
public GameObject levelscript;
public int level;
public void Start()
GameObject scoreEventTrigger = GameObject.Find("ScoreEventTrigger");
LevelManager levelManager = scoreEventTrigger.GetComponent<LevelManager>();
level = levelManager.currentLevel;
public void OpenPanel1()
if (level == 1)
if (Panel1 != null)
Panel1.SetActive(true);
public void OpenPanel2()
if (level == 2)
if (Panel2 != null)
Panel2.SetActive(true);
}
c# user-interface unity3d
New contributor
So this is in line with another question i asked but im taking a different route. The question i have is in this script i am finding the level of the player from the LevelManager script. Im going to use a different panel for each player level and make them active as the level increases. Not the best way i understand. The problem i am having is that level in this script is not updating with currentLevel in my other script so the panels are not turning on because the level is always 0. Any help is appreciated. Neil
public GameObject Panel1;
public GameObject Panel2;
public GameObject Panel3;
public GameObject levelscript;
public int level;
public void Start()
GameObject scoreEventTrigger = GameObject.Find("ScoreEventTrigger");
LevelManager levelManager = scoreEventTrigger.GetComponent<LevelManager>();
level = levelManager.currentLevel;
public void OpenPanel1()
if (level == 1)
if (Panel1 != null)
Panel1.SetActive(true);
public void OpenPanel2()
if (level == 2)
if (Panel2 != null)
Panel2.SetActive(true);
}
c# user-interface unity3d
c# user-interface unity3d
New contributor
New contributor
New contributor
asked 2 days ago
NeilNeil
11
11
New contributor
New contributor
This looks okay to me. Are you sure you are correctly adjustingcurrentLevel
inLevelManager
?
– Ali Kanat
2 days ago
Thanks for replying @AliKanat. Yup the score adjusts perfectly in the game. Just not on the button this script is attached to.
– Neil
2 days ago
add a comment |
This looks okay to me. Are you sure you are correctly adjustingcurrentLevel
inLevelManager
?
– Ali Kanat
2 days ago
Thanks for replying @AliKanat. Yup the score adjusts perfectly in the game. Just not on the button this script is attached to.
– Neil
2 days ago
This looks okay to me. Are you sure you are correctly adjusting
currentLevel
in LevelManager
?– Ali Kanat
2 days ago
This looks okay to me. Are you sure you are correctly adjusting
currentLevel
in LevelManager
?– Ali Kanat
2 days ago
Thanks for replying @AliKanat. Yup the score adjusts perfectly in the game. Just not on the button this script is attached to.
– Neil
2 days ago
Thanks for replying @AliKanat. Yup the score adjusts perfectly in the game. Just not on the button this script is attached to.
– Neil
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
Your loading your script only on start.
You need to check your levelscore when you fire some event, for example "onGetXp". On this event you check your level and apply panel.
Thanks for this. It makes sense. Can you post an example for me? i tried making a new function and also tried it in the update function. Thanks in advance for your help @joreldraw
– Neil
2 days ago
For a good example i need to know more about your xp or score system and your Levelmanager. But the easy way is to check your level everytime you got xp or score, not only on the start. if not you only check 1 time your level at the beggining.
– joreldraw
yesterday
Would a button onclick method work here? because i increment xp in a ontriggerenter event and then when currentxp >= neededxp i call the LevelUp function. So could i create a function in the above script that calls everything in the start method an instead calls it inside a button onclick event and then assign that in the inspector? Would that work? Or what other information do you need to know? Thank you again for your help @joreldraw
– Neil
yesterday
Would work if is the only way to increment xp, ontriggerenter you do all what you do for the xp and last call the levelup function to check.
– joreldraw
yesterday
Can you provide an example or do you need more information? The ontriggerenter function is the only way that the player gets xp. @joreldraw
– Neil
yesterday
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Neil is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023441%2fvariable-not-updating-on-other-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your loading your script only on start.
You need to check your levelscore when you fire some event, for example "onGetXp". On this event you check your level and apply panel.
Thanks for this. It makes sense. Can you post an example for me? i tried making a new function and also tried it in the update function. Thanks in advance for your help @joreldraw
– Neil
2 days ago
For a good example i need to know more about your xp or score system and your Levelmanager. But the easy way is to check your level everytime you got xp or score, not only on the start. if not you only check 1 time your level at the beggining.
– joreldraw
yesterday
Would a button onclick method work here? because i increment xp in a ontriggerenter event and then when currentxp >= neededxp i call the LevelUp function. So could i create a function in the above script that calls everything in the start method an instead calls it inside a button onclick event and then assign that in the inspector? Would that work? Or what other information do you need to know? Thank you again for your help @joreldraw
– Neil
yesterday
Would work if is the only way to increment xp, ontriggerenter you do all what you do for the xp and last call the levelup function to check.
– joreldraw
yesterday
Can you provide an example or do you need more information? The ontriggerenter function is the only way that the player gets xp. @joreldraw
– Neil
yesterday
|
show 1 more comment
Your loading your script only on start.
You need to check your levelscore when you fire some event, for example "onGetXp". On this event you check your level and apply panel.
Thanks for this. It makes sense. Can you post an example for me? i tried making a new function and also tried it in the update function. Thanks in advance for your help @joreldraw
– Neil
2 days ago
For a good example i need to know more about your xp or score system and your Levelmanager. But the easy way is to check your level everytime you got xp or score, not only on the start. if not you only check 1 time your level at the beggining.
– joreldraw
yesterday
Would a button onclick method work here? because i increment xp in a ontriggerenter event and then when currentxp >= neededxp i call the LevelUp function. So could i create a function in the above script that calls everything in the start method an instead calls it inside a button onclick event and then assign that in the inspector? Would that work? Or what other information do you need to know? Thank you again for your help @joreldraw
– Neil
yesterday
Would work if is the only way to increment xp, ontriggerenter you do all what you do for the xp and last call the levelup function to check.
– joreldraw
yesterday
Can you provide an example or do you need more information? The ontriggerenter function is the only way that the player gets xp. @joreldraw
– Neil
yesterday
|
show 1 more comment
Your loading your script only on start.
You need to check your levelscore when you fire some event, for example "onGetXp". On this event you check your level and apply panel.
Your loading your script only on start.
You need to check your levelscore when you fire some event, for example "onGetXp". On this event you check your level and apply panel.
answered 2 days ago
joreldrawjoreldraw
1,143719
1,143719
Thanks for this. It makes sense. Can you post an example for me? i tried making a new function and also tried it in the update function. Thanks in advance for your help @joreldraw
– Neil
2 days ago
For a good example i need to know more about your xp or score system and your Levelmanager. But the easy way is to check your level everytime you got xp or score, not only on the start. if not you only check 1 time your level at the beggining.
– joreldraw
yesterday
Would a button onclick method work here? because i increment xp in a ontriggerenter event and then when currentxp >= neededxp i call the LevelUp function. So could i create a function in the above script that calls everything in the start method an instead calls it inside a button onclick event and then assign that in the inspector? Would that work? Or what other information do you need to know? Thank you again for your help @joreldraw
– Neil
yesterday
Would work if is the only way to increment xp, ontriggerenter you do all what you do for the xp and last call the levelup function to check.
– joreldraw
yesterday
Can you provide an example or do you need more information? The ontriggerenter function is the only way that the player gets xp. @joreldraw
– Neil
yesterday
|
show 1 more comment
Thanks for this. It makes sense. Can you post an example for me? i tried making a new function and also tried it in the update function. Thanks in advance for your help @joreldraw
– Neil
2 days ago
For a good example i need to know more about your xp or score system and your Levelmanager. But the easy way is to check your level everytime you got xp or score, not only on the start. if not you only check 1 time your level at the beggining.
– joreldraw
yesterday
Would a button onclick method work here? because i increment xp in a ontriggerenter event and then when currentxp >= neededxp i call the LevelUp function. So could i create a function in the above script that calls everything in the start method an instead calls it inside a button onclick event and then assign that in the inspector? Would that work? Or what other information do you need to know? Thank you again for your help @joreldraw
– Neil
yesterday
Would work if is the only way to increment xp, ontriggerenter you do all what you do for the xp and last call the levelup function to check.
– joreldraw
yesterday
Can you provide an example or do you need more information? The ontriggerenter function is the only way that the player gets xp. @joreldraw
– Neil
yesterday
Thanks for this. It makes sense. Can you post an example for me? i tried making a new function and also tried it in the update function. Thanks in advance for your help @joreldraw
– Neil
2 days ago
Thanks for this. It makes sense. Can you post an example for me? i tried making a new function and also tried it in the update function. Thanks in advance for your help @joreldraw
– Neil
2 days ago
For a good example i need to know more about your xp or score system and your Levelmanager. But the easy way is to check your level everytime you got xp or score, not only on the start. if not you only check 1 time your level at the beggining.
– joreldraw
yesterday
For a good example i need to know more about your xp or score system and your Levelmanager. But the easy way is to check your level everytime you got xp or score, not only on the start. if not you only check 1 time your level at the beggining.
– joreldraw
yesterday
Would a button onclick method work here? because i increment xp in a ontriggerenter event and then when currentxp >= neededxp i call the LevelUp function. So could i create a function in the above script that calls everything in the start method an instead calls it inside a button onclick event and then assign that in the inspector? Would that work? Or what other information do you need to know? Thank you again for your help @joreldraw
– Neil
yesterday
Would a button onclick method work here? because i increment xp in a ontriggerenter event and then when currentxp >= neededxp i call the LevelUp function. So could i create a function in the above script that calls everything in the start method an instead calls it inside a button onclick event and then assign that in the inspector? Would that work? Or what other information do you need to know? Thank you again for your help @joreldraw
– Neil
yesterday
Would work if is the only way to increment xp, ontriggerenter you do all what you do for the xp and last call the levelup function to check.
– joreldraw
yesterday
Would work if is the only way to increment xp, ontriggerenter you do all what you do for the xp and last call the levelup function to check.
– joreldraw
yesterday
Can you provide an example or do you need more information? The ontriggerenter function is the only way that the player gets xp. @joreldraw
– Neil
yesterday
Can you provide an example or do you need more information? The ontriggerenter function is the only way that the player gets xp. @joreldraw
– Neil
yesterday
|
show 1 more comment
Neil is a new contributor. Be nice, and check out our Code of Conduct.
Neil is a new contributor. Be nice, and check out our Code of Conduct.
Neil is a new contributor. Be nice, and check out our Code of Conduct.
Neil is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023441%2fvariable-not-updating-on-other-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This looks okay to me. Are you sure you are correctly adjusting
currentLevel
inLevelManager
?– Ali Kanat
2 days ago
Thanks for replying @AliKanat. Yup the score adjusts perfectly in the game. Just not on the button this script is attached to.
– Neil
2 days ago