Question by
The_assassin_91 · Jan 17, 2017 at 06:03 PM ·
objectscalecallback
Manipulating Objects in callback
Hello, I have run into a problem when trying to scale and re-position an object in a callback. For some reason nothing happens to the object when I change the scale or position but I can destroy the object or change the objects material so I know it is linked correctly. I am not sure why it wont work is it something that is just not possible. I have left some example code of what I am doing, If anybody can help me it would be greatly appreciated.
//this is just example code but it is basically the same format of my original code
//without the unnecessary code
void createCallBack(){
GameObject obj = (GameObject) GameObject.Instantiate(Obj, pos, rotation);
ObjectClass objData = new ObjectClass();
objData.RegisterCallback((data)=>{ManipulateObject(data,obj);});
}
void ManipulateObject(ObjectClass data, GameObject obj){
//this part works
obj.GetComponent<MeshRenderer>().material = grassSP;
//this doesn't work
Vector3 scale = obj.transform.localScale;
Vector3 pos = obj.transform.position;
scale.x = 0.5f;
pos.x += 20.5f;
obj.transform.localScale = scale;
obj.transform.position = pos;
}
Comment
Your answer
Follow this Question
Related Questions
Gradually editing the scale of an object 1 Answer
Change object scale by touch (in game) ^ 0 Answers
Scale object between 2 moving objects 0 Answers
Stuck with scaling an object 1 Answer