Example #1
0
    private void GenerateBehaivour()
    {
        if (HasEmptyObjects(objectsToPlace, this))
        {
            return;
        }

        S_IODefinition ioDef = SpatialStoriesAPI.CreateIODefinition(behaviourName);

        int counter = objectsToPlace.Count;

        S_InteractionDefinition start = ioDef.CreateInteractionDefinition(string.Concat("Start ", behaviourName));
        S_InteractionDefinition place = ioDef.CreateInteractionDefinition(string.Concat("Instantiate ", behaviourName));

        place.CreateArkitInstantiateAction((Gaze_ArkitPlaceConstraints)constraintsIndex, heightOffset, distanceFromCamera, ChooseMode.RANDOM == (ChooseMode)chooseModeIndex, NumInstantiatiations.FINITE == (NumInstantiatiations)numInstantiationsIndex, numObjectsToInstantiate, objectsToPlace, objectsToPlaceCursor);
        place.CreateDependency(start.GUID);

        place.CreateTouchCondition();
        S_InteractionDefinition end = null;

        if (numInstantiationsIndex == (int)NumInstantiatiations.FINITE)
        {
            end       = ioDef.CreateInteractionDefinition(string.Concat("End ", behaviourName));
            end.Delay = 0.03f;
        }

        if (constraintsIndex == (int)Gaze_ArkitPlaceConstraints.OVER_A_PLANE)
        {
            place.CreateGazeCondition(ioDef.GUID, Gaze_HoverStates.IN, Gaze_GazeConstraints.PLANE);
        }
        else if (constraintsIndex == (int)Gaze_ArkitPlaceConstraints.OVER_AN_OBJECT)
        {
            place.CreateGazeCondition(ioDef.GUID, Gaze_HoverStates.IN, Gaze_GazeConstraints.ANY_OBJECT);
        }
        else if (constraintsIndex == (int)Gaze_ArkitPlaceConstraints.OVER_AN_IMAGE)
        {
            place.CreateGazeCondition(ioDef.GUID, Gaze_HoverStates.IN, Gaze_GazeConstraints.IMAGE);
        }


        Gaze_InteractiveObject obj = SpatialStoriesAPI.CreateInteractiveObject(ioDef, false);

        SpatialStoriesAPI.WirePendingDependencies();

        // Set the trigger counter condition
        if (numInstantiationsIndex == (int)NumInstantiatiations.FINITE)
        {
            CC_CountTriggers c = SpatialStoriesAPI.GetObjectOfTypeWithGUID(end.GUID).gameObject.AddComponent <CC_CountTriggers>();
            c.NumTimes    = numObjectsToInstantiate;
            c.Interaction = SpatialStoriesAPI.GetObjectOfTypeWithGUID(place.GUID).GetComponent <Gaze_Conditions>();
            Gaze_Conditions conditions = c.GetComponent <Gaze_Conditions>();
            conditions.customConditionsEnabled = true;
            conditions.customConditions.Add(c);
        }

        Close();
    }
    private void GenerateBehaivour()
    {
        if (Behaviour_ObjectInstantiator.HasEmptyObjects(objectsToPlace, this))
        {
            return;
        }

        S_IODefinition ioDef = SpatialStoriesAPI.CreateIODefinition(behaviourName);

        int counter = objectsToPlace.Count;

        S_InteractionDefinition start = ioDef.CreateInteractionDefinition(string.Concat("Start ", behaviourName));
        string guidLastInteraction    = start.GUID;

        for (int i = counter - 1; i >= 0; i--)
        {
            GameObject objectToPlace = objectsToPlace[i];
            if (objectToPlace != null)
            {
                GameObject cursor = objectsToPlaceCursor[i];
                if (cursor != null)
                {
                    S_InteractionDefinition cursorDef = ioDef.CreateInteractionDefinition(string.Concat("Enable Cursor ", objectToPlace.name));
                    cursorDef.CreateDependency(guidLastInteraction);
                    cursorDef.CreateArkitPlaceCursorAction(cursor, (Gaze_ArkitPlaceConstraints)constraintsIndex, heightOffset, distanceFromCamera);
                    guidLastInteraction = cursorDef.GUID;
                }

                S_InteractionDefinition placeObjectDef = ioDef.CreateInteractionDefinition(string.Concat("Place ", objectToPlace.name));
                placeObjectDef.CreateTouchCondition();

                if (constraintsIndex == (int)Gaze_ArkitPlaceConstraints.OVER_A_PLANE)
                {
                    placeObjectDef.CreateGazeCondition(ioDef.GUID, Gaze_HoverStates.IN, Gaze_GazeConstraints.PLANE);
                }
                else if (constraintsIndex == (int)Gaze_ArkitPlaceConstraints.OVER_AN_OBJECT)
                {
                    placeObjectDef.CreateGazeCondition(ioDef.GUID, Gaze_HoverStates.IN, Gaze_GazeConstraints.ANY_OBJECT);
                }

                placeObjectDef.CreateArkitMoveAction(objectToPlace, (Gaze_ArkitPlaceConstraints)constraintsIndex, heightOffset, distanceFromCamera, deactivateAtStart);

                placeObjectDef.CreateDependency(guidLastInteraction);

                // Check if we need to place a cursor
                if (cursor != null)
                {
                    S_InteractionDefinition cursorDeactivateDef = ioDef.CreateInteractionDefinition(string.Concat("Disable Cursor ", objectToPlace.name));
                    cursorDeactivateDef.CreateDependency(placeObjectDef.GUID);
                    cursorDeactivateDef.CreateArkitHidePlaceCursor(guidLastInteraction);
                    guidLastInteraction = cursorDeactivateDef.GUID;
                }
                else
                {
                    guidLastInteraction = placeObjectDef.GUID;
                }
            }
        }
        S_InteractionDefinition end = ioDef.CreateInteractionDefinition(string.Concat("End ", behaviourName));

        end.Delay = 0.03f;
        end.CreateDependency(guidLastInteraction);

        SpatialStoriesAPI.CreateInteractiveObject(ioDef, false);
        SpatialStoriesAPI.WirePendingDependencies();
    }