Change Script runtime with keeping reference
Hi i have problem with references between components I want to try modable game,and allow modding script i have few idea how it can be possible but for some o dont have tools or i dont know how.
I can create component instance from Runtime Loaded dll. There should be no problem. I can also replace old script by new script and also transfer all values
But there will be definetly case when i will want change a script which is referenced by some other script(s). And now i of course want to update that reference to new script
Possible options:
1) I have old object/scriupt and i would like to ask/findout if any other compoentn in scene has reference to it 2) I want find all components which has reference to that type of script i want change and i want check, and in some cases change that reference to new script
These twoo looks like nice solutions but i cant find any tools/possibilities in unity to do that way.
3) Somewhere save all referenece/all iportant referenece and check from that;
4) Every "script" will have somewhat method like checkCoponentAndReplace(Component old, Component new) which will replace odl component by new one
Point 4 is easiest one i think, but probably slowest one. There can be definelty some workarounds how to speed it up, but i dont see any when i will first load scene and i will need to change scripts to new one, any basically for almost all run some method(s) like this.
Any tips or sites when i can find better way?
Can your problem like you're talking to 5 year olds? Sometimes when you've been working on something for awhile, it's possible to give an explanation that only makes sense to you.
OF course :D 1) I have gameobject in scene with component $$anonymous$$oveScript (script c#) 2)) I have for example gameobject2 with component SomeLogic (c# script ), with property/reference to "$$anonymous$$oveScript " -> gameobject1 3) I will have mod which replace $$anonymous$$oveScript with $$anonymous$$oveScriptExt which was write by moders outside our project) 4) $$anonymous$$oveScriptExt will be added as DLL which i load 5) i load also config which will say i want replace all $$anonymous$$oveScript with $$anonymous$$oveScriptExt
6) i Replace 7) How to inform gameobject2 and sacript SomeLogic that his reference to $$anonymous$$oveScript is deleted and replaced by $$anonymous$$oveScriptExt
Your answer
Follow this Question
Related Questions
Move a separate object forward on collision between particle system and another object 0 Answers
Having transitions between two VideoPlayers triggered by clicking "x" times in a text layer 0 Answers
How can I reset the score counter? 2 Answers
Making an image appear 0 Answers
Saving an image's state 2 Answers