示例#1
0
 public void spawnRegisteredChildPrefab(RegisteredObject obj)
 {
     RegisteredObject.Create(
         "core/prefabs/entities",
         "TestEntityPrefab",
         Vector3.zero,
         Quaternion.identity,
         obj.transform);
 }
示例#2
0
 public void spawnRegisteredPrefabs(int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         RegisteredObject.Create(
             "core/prefabs/entities",
             "TestEntityPrefab",
             (Vector3)Random.insideUnitCircle,
             Quaternion.identity);
     }
 }
示例#3
0
        public void Register <T>(string objectId, T obj, params Type[] nestedTypes)
        {
            // Create registered object
            var registeredObect = RegisteredObject.Create(objectId, obj);

            // Register property objects
            foreach (var property in typeof(T).GetContractProperties().Where(p => nestedTypes.Contains(p.PropertyType))
                     )
            {
                object value = property.GetValue(obj);
                if (value != null)
                {
                    var genericRegisterMethod = GetType().GetMethods().First(m => m.Name == nameof(Register) && m.GetParameters().Count() == 1);
                    genericRegisterMethod.MakeGenericMethod(property.PropertyType).Invoke(this, new object[] { value });
                }
            }

            // Store registered object
            _registeredObjects.Add(objectId, registeredObect);
        }