Hi I know you're smart enough to fix any logical errors in the c# script for unity…
- User
Hi I know you're smart enough to fix any logical errors in the c# script for unity below, btw the context is second life viewer code.
private void DoNewSceneObject(SimObject simObject) { // don't bother with objects in other regions for now. if (_config.LimitToCurrentRegion) return;
var localID = simObject.LocalID; var heirarchyHolder = Instantiate(blank); heirarchyHolder.name = $"Heirarch Holder ({localID})"; var gameObject = Instantiate(cube); gameObject.name = $"Object ({localID})"; gameObject.transform.parent = heirarchyHolder.transform; gameObject.transform.localPosition = Vector3.zero; // disable rendering of the newly created object. // Its currently a cube, and probably not what we // want to show anyway. var meshRenderer = gameObject.GetComponent<MeshRenderer>(); meshRenderer.enabled = false; var meshHolder = Instantiate(blank); meshHolder.name = $"Mesh Holder({localID})"; meshHolder.transform.parent = heirarchyHolder.transform; var sceneObject = new SceneObject() { LocalID = simObject.LocalID, HeirachyHolder = heirarchyHolder, GameObject = gameObject, MeshHolder = meshHolder, SimObject = simObject, }; if (!_renderManager.SceneObjects.Add(sceneObject)) { // oh no, something when wrong. Lets clean up our mess. Destroy(heirarchyHolder); } gameObject.transform.localScale = simObject.Scale; // at this point a note was made of the HashCode of the primData. // It looks like its purpose is to know if the object has changed. // scenePrims[prim.LocalID].ConstructionHash = prim.PrimData.GetHashCode(); if (simObject.ParentID != 0) { // this object has a parent. var sceneParent = _renderManager.SceneObjects.Get(simObject.ParentID); if (sceneParent is null) { // AllSimObjects is not supposed to put orphans into the newObjectQueue. // I'm not sure why this happening -Kage _log.Render_NewOrphanObject(simObject.LocalID, simObject.ParentID); // Warn _newObjectQueue.Enqueue(simObject); // Try again later. } if (simObject.IsHud()) { } else { heirarchyHolder.transform.parent = sceneParent.GameObject.transform.parent; } } heirarchyHolder.transform.SetLocalPositionAndRotation( simObject.SimPosition, simObject.SimRotation); // at this point in the old object management, the render method would have been called. // that render method is kind of hard to follow, but really the next step is to setup Renderes on the objects, // which means creating an Array of UnityEngine.Renderer from Generated classic prim data, downloaded mesh data // or downloaded sculpt data. _needRenderDataQueue.Enqueue(sceneObject);}
- Assistant