public override void OnEnable() { headerName = HeaderElementAddonName; headerColor = HeaderElementAddonColor; base.OnEnable(); _target = (NSTElementComponent)target; _target.nstElementsEngine = NSTElementsEngine.EnsureExistsOnRoot(_target.transform, false); nstElementsEngine = _target.nstElementsEngine; // First make sure this is unique for this gameobject MakeAllNamesUnique(_target.gameObject); }
// Construct public Frame(NetworkSyncTransform _nst, int _frameid, Vector3 _pos, CompressedElement _compPos, Quaternion _rot) //, PositionElement[] positionElements, RotationElement[] rotationElements) { nst = _nst; ee = _nst.nstElementsEngine; rootPos = _pos; compPos = _compPos; state = nst.State; frameid = _frameid; customData = new byte[128]; //TODO: Make this size a user setting // references //tes = _nst.nstElementsEngine.transformElements; rootRotElementFrame = nst.rootRotationElement.frames[_frameid]; }
// Construct public Frame(NetworkSyncTransform nst, int frameid, Vector3 pos, CompressedElement compPos) //, PositionElement[] positionElements, RotationElement[] rotationElements) { this.rootPosCrusher = WorldBoundsSO.single.worldBoundsGroups[0].crusher; this.nst = nst; this.ee = nst.nstElementsEngine; this.rootPos = pos; this.compPos.CopyFrom(compPos); this.state = nst.State; this.frameid = frameid; this.customData = new byte[128]; //TODO: Make this size a user setting this.checkSceneIndex = HeaderSettings.Single.includeSceneIndex; this.sceneIndex = NSTSceneManager.CurrentSceneIndex; this.rootBitCullLevel = BitCullingLevel.NoCulling; this.rootRotElementFrame = nst.rootRotationElement.frames[frameid]; }
/// <summary> /// Ensure all required dependencies are added for this NST to work. Can be called often in edit mode, and should be. /// </summary> /// <param name="nst"></param> /// <param name="silence"></param> public static void EnsureAllNSTDependencies(this NetworkSyncTransform nst, SerializedObject serializedObject, bool silence = false) { EnsureSceneNetLibDependencies(); if (Application.isPlaying) { return; } // If user tried to put NST where it shouldn't be... remove it and all of the required components it added. if (nst.transform.parent != null) { XDebug.LogError("NetworkSyncTransform must be on the root of an prefab object."); nst.nstElementsEngine = nst.transform.GetComponent <NSTElementsEngine>(); NSTNetAdapter.RemoveAdapter(nst); Object.DestroyImmediate(nst); if (nst.nstElementsEngine != null) { Object.DestroyImmediate(nst.nstElementsEngine); EditorUtility.SetDirty(nst.gameObject); } return; } nst.nstElementsEngine = NSTElementsEngine.EnsureExistsOnRoot(nst.transform, false); nst.na = EditorUtils.EnsureRootComponentExists <NSTNetAdapter>(nst.gameObject, false); //AddRewindEngine(nst); //// Add this NST to the prefab spawn list (and as player prefab if none exists yet) as an idiot prevention NSTNetAdapter.AddAsRegisteredPrefab(nst.gameObject, true, silence); return; }
public override void OnNstPostAwake() { base.OnNstPostAwake(); nstElementsEngine = nst.nstElementsEngine; }