示例#1
0
        public void Check()
        {
            List <ObjectId> keys = new List <ObjectId>(AllObjects.Keys);

            foreach (var opId in keys)
            {
                ObjectPrivate op = ScenePrivate.FindObject(opId);
                if (op == null ||
                    !op.IsValid)
                {
                    Error(op.Name);
                    AllObjects.Remove(opId);
                    continue;
                }

                int oldScriptCount = AllObjects[opId];
                int newScriptCount = op.LookupScripts().Length;
                if (oldScriptCount > newScriptCount)
                {
                    Error(op.Name);
                }

                // Either still initializing and adding scripts or only logging.
                AllObjects[opId] = newScriptCount;
            }
        }
示例#2
0
        // Init() is where the script is setup and is run when the script starts.
        public override void Init()
        {
            foreach (var rb in Objects)
            {
                if (rb == null)
                {
                    continue;
                }

                ObjectPrivate op = ScenePrivate.FindObject(rb.ComponentId.ObjectId);
                if (op != null)
                {
                    var scripts = op.LookupScripts();
                    AllObjects.Add(op.ObjectId, scripts == null ? 0 : scripts.Length);
                }
            }

            Timer.Create(60, 60, Check);
        }