示例#1
0
        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);
        }
示例#2
0
        // 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];
        }
示例#3
0
        // 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];
        }
示例#4
0
        /// <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;
        }
示例#5
0
 public override void OnNstPostAwake()
 {
     base.OnNstPostAwake();
     nstElementsEngine = nst.nstElementsEngine;
 }