public override object Create(object instance) { CreatedObjects.Add(instance); switch (instance.GetType().Name) { case "Project": return(555L); default: return(555); } }
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); }
/* * 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); }
public override object Create(object instance) { CreatedObjects.Add(instance); return(446L); }