Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Simple Powerpoint like animations in Unity

Discussion in 'AR/VR (XR) Discussion' started by accom, Jul 22, 2017.

  1. accom

    accom

    Joined:
    Apr 12, 2017
    Posts:
    9
    I am new to programming in Unity but I have this idea of a Powerpoint like presentation in VR.
    The user presses on the controller and objects appear or disappear in a predefined order. Users without programming skills can arrange the objects and define when they should appear or disappear.
    Can this be achieved?

    I thought about this way to do it. I use the same script and attach it to all the objects. It defines:
    1) Action: how the object should behave – appear/disappear
    2) A number which defines when the action should take place

    A “master script” should first identify all the objects with the script attached to them. Then turn all objects that should appear “off”.
    On pressing a button on the controller the action of the object with the number 1 should be started. Then on button press the action of object attached with the number 2 and so on.
    Is such a thing feasible?
    I have no idea how to program this.
    Can anyone help.
     
  2. guillermoi

    guillermoi

    Joined:
    Sep 20, 2012
    Posts:
    27
    Hey.

    Well, just an "immersive presentation" could be done, and you should probably do/experience that first and see if you like it or if you want something else.

    But then doing a "PowerPoint like editor that outputs the presentations as immersive VR apps" it a whole other story. Way more difficult and ambitious.
     
  3. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    You mention initial spec as being "Powerpoint like", does this mean you are aiming for user created presentions?:
    Simple example being allowing the user to browse their photo folder to build a stack of slide content.

    If that is the case then there's really no reason to hold any more than two slides in scene at any one time: just runtime load new texture2d before performing transition to new slide.

    So yeah... your initial thought of a "master script" is pretty much how I would handle it.

    In unity scene editor:
    Throw an empty prefab named "master" in scene with a "master.cs" script on it, that's your entry point.

    Make two quads in scene each with separate material, then you can change transparency or scale quads etc to have a transition as you like.

    Make both quads be children of "master". master is at(0,0,0), quads both positioned as you want your virtual screens, the appropriate Z distance and X/Y scale. You could even get fancy and UV wrap a section of a sphere later in dev.

    In vis studio:

    Below is basic master.cs framework to make a sequential slideshow for N slides with scene setup as described above.

    Code (CSharp):
    1.  
    2. //SILICONDROID.COM OPENSOURCE
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6.  
    7. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    8. //    CLASS: master
    9. public class master : MonoBehaviour
    10. {
    11.     //     VISIBLE SLIDE QUADS
    12.     private Transform tSlide0;
    13.     private Transform tSlide1;
    14.     private bool bShowingSlide1;
    15.  
    16.     //     LIST OF TEXTURE PATHS TO SHOW ON SLIDES
    17.     private int iSlideIndex = 0;
    18.     public List<string> lsSlidePaths = new List<string>();
    19.  
    20.     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    21.     //    AWAKE
    22.     private void Awake()
    23.     {
    24.         tSlide0 = transform.GetChild(0);
    25.         if(!tSlide0)
    26.         {
    27.             Debug.LogWarning("CANT GET SLIDE 0");
    28.             return;
    29.         }
    30.  
    31.         tSlide1 = transform.GetChild(1);
    32.         if (!tSlide1)
    33.         {
    34.             Debug.LogWarning("CANT GET SLIDE 1");
    35.             return;
    36.         }
    37.  
    38.         //  HIDE BOTH SLIDES
    39.         ShowSlide(-1);
    40.  
    41.         //  HARDCODE TEST SLIDES
    42.         iSlideIndex = 0;
    43.         lsSlidePaths.Add("SOME PATH TO A PICTURE 1");
    44.         lsSlidePaths.Add("SOME PATH TO A PICTURE 2");
    45.         lsSlidePaths.Add("SOME PATH TO A PICTURE 3");
    46.         lsSlidePaths.Add("SOME PATH TO A PICTURE 4");
    47.         lsSlidePaths.Add("SOME PATH TO A PICTURE 5");
    48.         lsSlidePaths.Add("SOME PATH TO A PICTURE 6");
    49.         lsSlidePaths.Add("SOME PATH TO A PICTURE 7");
    50.     }
    51.  
    52.     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    53.     //    UPDATE
    54.     private void Update()
    55.     {
    56.         //  LISTEN FOR USER INPUT
    57.         if(Input.GetKeyDown(KeyCode.Space))
    58.         {
    59.             NextSlide();
    60.         }
    61.     }
    62.  
    63.  
    64.     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    65.     //    NEXT SLIDE, COMMENTS ASSUME SIMPLE INSTANT SLIDE CHANGE
    66.     private void NextSlide()
    67.     {
    68.         //  GET SLIDE TEXTURE PATH
    69.         string sTexturePath = lsSlidePaths[iSlideIndex];
    70.  
    71.         //INC LIST POINTER, WRAP AT END
    72.         iSlideIndex = (iSlideIndex + 1) % lsSlidePaths.Count;
    73.  
    74.         //  TOGGLE SLIDE DOUBLE BUFFER
    75.         bShowingSlide1 = !bShowingSlide1;
    76.         if(bShowingSlide1)
    77.         {
    78.             LoadTexture(tSlide1, sTexturePath);
    79.             ShowSlide(1);
    80.             Debug.Log("Now showing " + sTexturePath + " in slide 1");
    81.         }
    82.         else
    83.         {
    84.             LoadTexture(tSlide0, sTexturePath);
    85.             ShowSlide(0);
    86.             Debug.Log("Now showing " + sTexturePath + " in slide 0");
    87.         }
    88.     }
    89.  
    90.     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    91.     //    LOAD TEXTURE TO RELEVANT QUAD
    92.     private void LoadTexture(Transform tSlide, string sTexturePath)
    93.     {
    94.         //  EXERCISE FOR READER: apply passed texture to passed slides material.
    95.     }
    96.  
    97.     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    98.     //    SHOW A SLIDE
    99.     private void ShowSlide(int iSlide)
    100.     {
    101.         if(iSlide == -1)
    102.         {
    103.             //  EXERCISE FOR READER: HIDE tSlide0, HIDE tSlide1
    104.         }
    105.         else if(iSlide == 0)
    106.         {
    107.             //  EXERCISE FOR READER: SHOW tSlide0, HIDE tSlide1
    108.         }
    109.         else
    110.         {
    111.             //  EXERCISE FOR READER: SHOW tSlide1, HIDE tSlide0
    112.         }
    113.     }
    114. }
    115.  
     
    Last edited: Jul 22, 2017
  4. accom

    accom

    Joined:
    Apr 12, 2017
    Posts:
    9
    Hi SiliconDroid.

    As always a great answer. I was indeed thinking aiming at a user created presentation.

    It should result in a small lecture. I arrange some basic objects in virtual space, like 3D objects, and some text elements. Then I attach to each object the tags at which number they should appear or disappear.

    Let’s say I want to teach about a sculpture. So at first there is the sculpture present. On pressing the button a plane with the name of the artist appears in front of it (Attributes: Plane, Appear, No1). Then again on pressing a button some arrows with explanations aiming at different parts of the sculpture appear (Attributes: Text, Arrows, Appear, No.2). Then again on pressing a button the last objects disappear (Attributes: Text, Arrows, disappear, No.3) and the next sculpture in the other corner of the room appear (Attributes: Next sculpture, Appear, No3).

    My dream is that somebody can arrange these objects using Unity and then without typing their "names" in a script, just by attaching a script with the two input variables "Appear"/"Disaster" and the "Number" to them.
    Do you think that’s feasible?

    I thought about "SetActive();" to make things appear and disappear.
     
  5. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    OK so you want to build a template like system, your end users would have to use unity to create a presentation.

    Yes, create a script like object.cs that you attach to anything that you drag into scene. That script should hold public vars exposed to the inspector to hold info. That script should do all its setup in awake.

    Then create a single master.cs that will manage all objects in scene, it calls various object.cs public functions.

    To set visibility get the renderer of an object and use renderer.enabled = true/false. You can also use set active, that will prevent objects update loop running.
     
  6. accom

    accom

    Joined:
    Apr 12, 2017
    Posts:
    9
    It sounds so seasy when you say it :D