示例#1
0
        public override object Create(object instance)
        {
            CreatedObjects.Add(instance);

            switch (instance.GetType().Name)
            {
            case "Project":
                return(555L);

            default:
                return(555);
            }
        }
示例#2
0
    public void Add(object obj)
    {
        if (obj == null)
        {
            return;
        }
        var type = obj.GetType();

        if (type.IsValueType || type == typeof(string))
        {
            return;
        }
        CreatedObjects.Add(obj);
    }
        private void CreateObject()
        {
            CurrentState = ObjectManagerState.CREATING;

            // Create the object at midpoint between the two pinches
            Vector3 position = (_rightHandPinchDetector.Position - _leftHandPinchDetector.Position) * 0.5f;

            // Create the object and add to a list of objects
            GameObject newObject = Instantiate(_interactableObjects[_currentObjectTypeIndex].prefab, position, Quaternion.identity, _objectContainer) as GameObject;

            _currentObject = newObject.GetComponent <IInteractableObjectController>();
            CreatedObjects.Add(_currentObject);
            _currentObject.Create(_interactionManager, _leftHandPinchDetector, _rightHandPinchDetector);
        }
示例#4
0
    /*
     * Destroys a given prefab.
     */
    public static void DestroyObject(GameObject obj)
    {
        // Remove prefab from createdPrefabs list, or throw error if it's not in list.
        if (!CreatedObjects.Remove(obj))
        {
            throw new System.Exception("Cannot destroy prefab: No such prefab exists.");
        }

        // If destroying a parent object, we also need to destroy it's children.
        foreach (Transform child in obj.transform)
        {
            DestroyObject(child.gameObject);
        }
        // Destroy the object.
        Destroy(obj);
    }
示例#5
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            if (RenderContext != null)
            {
                RenderContext.Dispose();
            }
            if (BackBuffer != null)
            {
                BackBuffer.Dispose();
            }
            if (DepthStencilBuffer != null)
            {
                DepthStencilBuffer.Dispose();
            }
            //if (Factory != null)
            //Factory.Dispose();
            if (swapChain != null)
            {
                swapChain.Dispose();
            }

            GraphicsObject[] created = CreatedObjects.ToArray();
            for (int i = 0; i < created.Length; i++)
            {
                if (!created[i].IsDisposed)
                {
                    Log.Warning("{0} was not disposed! Created at:\r\n{1}", created[i].GetType().Name, created[i].CreationStack);
                    created[i].Dispose();
                }
            }
            CreatedObjects.Clear();

            if (Device != null)
            {
                Device.Dispose();
            }

            IsDisposed = true;
        }
示例#6
0
    /*
     * Creates a prefab by searching for one with the given name.
     * If prefab with specified name doesn't exist, it throws an error.
     */
    public static GameObject InstantiatePrefab(string prefabName, Vector3 position, Quaternion rotation)
    {
        // Find the prefab. If the prefab doesn't exist, throw an error.
        GameObject prefab = FindPrefabWithName(prefabName);

        if (prefab == null)
        {
            throw new System.Exception("Cannot instantiate prefab: No such prefab exists.");
        }
        // If it doesn't have a UniqueID object, also throw error.
        if (prefab.GetComponent <ES2UniqueID>() == null)
        {
            throw new System.Exception("Can't instantiate a prefab which has no UniqueID attached.");
        }

        // Instantiate our prefab and then add it to the created prefabs list.
        GameObject createdObject = Instantiate(prefab, position, rotation) as GameObject;

        CreatedObjects.Add(createdObject);

        return(createdObject);
    }
示例#7
0
 public override object Create(object instance)
 {
     CreatedObjects.Add(instance);
     return(446L);
 }