public override void SetupUsingApi(GameObject _interaction)
        {
            // Get the data and cast it
            string objectToGazeGUID = creationData[0].ToString();
            bool   gazeIn           = (bool)creationData[1];
            Gaze_GazeConstraints gazeConstraints = (Gaze_GazeConstraints)creationData[2];

            // Get the conditions obj
            Gaze_Conditions conditions = _interaction.GetComponent <Gaze_Conditions>();

            // Set al the necessary parameters
            conditions.gazeEnabled          = true;
            conditions.gazeIn               = gazeIn;
            constraints                     = gazeConstraints;
            conditions.gazeConstraintsIndex = (int)gazeConstraints;
            conditions.gazeStateIndex       = gazeIn ? (int)Gaze_HoverStates.IN : (int)Gaze_HoverStates.OUT;


            if (gazeConstraints == Gaze_GazeConstraints.OBJECT)
            {
                Gaze_InteractiveObject io = SpatialStoriesAPI.GetInteractiveObjectWithGUID(objectToGazeGUID);
                conditions.gazeColliderIO = io;
                // Setup the gaze collider
                Setup(io.GetComponentInChildren <Gaze_Gaze>().GetComponent <Collider>());
            }
            else
            {
                // Setup the gaze collider
                conditions.gazeColliderIO = conditions.RootIO;
                Setup(conditions.RootIO.GetComponentInChildren <Gaze_Gaze>().GetComponent <Collider>());
            }
        }
        public override void SetupUsingApi(GameObject _interaction)
        {
            // Get the data and cast it

            bool   touchIO      = (bool)creationData[1];
            string touchObjGUID = string.Empty;

            if (touchIO)
            {
                touchObjGUID = creationData[0].ToString();
            }

            // Get the conditions obj
            Gaze_Conditions conditions = _interaction.GetComponent <Gaze_Conditions>();

            // Enable touch for the conditions
            conditions.arkitTouchEnabled = true;

            Gaze_InteractiveObject io = null;

            if (touchIO)
            {
                io = SpatialStoriesAPI.GetInteractiveObjectWithGUID(touchObjGUID);
            }

            // this condition has the touch options on the gaze conditions script some we need to set it there too
            conditions.arkitTouchOption = touchIO
                ? Gaze_Conditions.ARKIT_TOUCH_OPTIONS.Object
                : Gaze_Conditions.ARKIT_TOUCH_OPTIONS.Anywhere;

            // Setup the touch condition
            Setup(conditions, io, touchIO);
        }
Example #3
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();
    }
Example #4
0
        public override void SetupUsingApi(GameObject _interaction)
        {
            // Get the dependency object
            string     dependencyGUID = creationData[0].ToString();
            GameObject dependency     = SpatialStoriesAPI.GetObjectOfTypeWithGUID(dependencyGUID);

            // Get the conditions of this depdenency
            Gaze_Conditions condition = _interaction.GetComponent <Gaze_Conditions>();

            // Set this condition as dependent
            condition.dependent = true;

            // Add a new depdenency on the dependency map
            gazeConditionsScript = condition;
            dependentGameObject  = dependency;
            triggerStateIndex    = (int)DependencyTriggerEventsAndStates.Triggered;
            onTrigger            = true;
            condition.ActivateOnDependencyMap.dependencies.Add(this);
        }
    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();
    }
    public override void SetupUsingApi(GameObject _interaction)
    {
        string gazeConditionsGUID = (string)creationData[0];

        CursorPlacerAction = SpatialStoriesAPI.GetObjectOfTypeWithGUID(gazeConditionsGUID).GetComponent <CA_ShowPlaceCursor>();
    }