Beispiel #1
0
 // ######################## UNITY EVENT FUNCTIONS ######################## //
 private void Update()
 {
     // register the object if it isnt in the list already
     if (!VolumetricObjectsRenderer.Contains(this))
     {
         VolumetricObjectsRenderer.AddObj(this);
     }
 }
Beispiel #2
0
    // ######################## FUNCTIONALITY ######################## //

    #region EDITOR
    #if UNITY_EDITOR
    /// <summary>
    /// Creates a Volumetric Object
    /// </summary>
    /// <param name="menuCommand"></param>
    /// <param name="type"></param>
    /// <param name="name"></param>
    /// <returns></returns>
    private static VolumetricObject CreateVolumetricObject(MenuCommand menuCommand, Types type, string name)
    {
        VolumetricObjectsRenderer rend = Camera.main.GetComponent <VolumetricObjectsRenderer>();

        if (rend == null)
        {
            Camera.main.gameObject.AddComponent <VolumetricObjectsRenderer>();
        }

        // create the Object
        GameObject       obj = new GameObject(name, typeof(VolumetricObject));
        VolumetricObject vo  = obj.GetComponent <VolumetricObject>();

        // set type
        vo.Type = type;

        // Ensure it gets reparented if this was a context click (otherwise does nothing)
        GameObjectUtility.SetParentAndAlign(obj, menuCommand.context as GameObject);
        // Register the creation in the undo system
        Undo.RegisterCreatedObjectUndo(obj, "Create " + obj.name);
        Selection.activeObject = obj;
        return(vo);
    }
Beispiel #3
0
 private void OnDisable()
 {
     // unregister the object
     VolumetricObjectsRenderer.Remove(this);
 }