Exemple #1
0
        public Gaze_ProximityEntry AddProximityEntry(Gaze_Conditions _conditions)
        {
            Gaze_ProximityEntry d = new Gaze_ProximityEntry();

            proximityEntryList.Add(d);
            return(d);
        }
Exemple #2
0
        public void AddProximityEntryToGroup(Gaze_InteractiveObject dependentObject)
        {
            Gaze_ProximityEntry p = new Gaze_ProximityEntry();

            p.dependentGameObject = dependentObject;
            proximityEntries.Add(p);
        }
Exemple #3
0
 public void RemoveCollidingObjectToEntry(Gaze_ProximityEntry _entry, Gaze_InteractiveObject _collidingObject, bool displayCollidingObjects = false)
 {
     _entry.RemoveCollidingObject(_collidingObject);
     if (displayCollidingObjects)
     {
         _entry.DisplayCollidingObjects();
     }
 }
        public override void SetupUsingApi(GameObject _interaction)
        {
            Gaze_Conditions conditions = _interaction.GetComponent <Gaze_Conditions>();

            conditions.proximityEnabled = true;

            // setup OnEnter / OnExit
            conditions.proximityMap.proximityStateIndex = (int)creationData[0];

            Gaze_ProximityEntry d = conditions.proximityMap.AddProximityEntry(conditions);

            d.dependentGameObject = SpatialStories.SpatialStoriesAPI.GetInteractiveObjectWithGUID(creationData[2].ToString());
            Gaze_ProximityEntry d2 = conditions.proximityMap.AddProximityEntry(conditions);

            d2.dependentGameObject = SpatialStories.SpatialStoriesAPI.GetInteractiveObjectWithGUID(creationData[3].ToString());

            // Require All
            conditions.requireAllProximities = (bool)creationData[1];
        }
Exemple #5
0
 public bool DeleteProximityEntry(Gaze_ProximityEntry d)
 {
     return(proximityEntryList.Remove(d));
 }
Exemple #6
0
        private void DisplayProximityList()
        {
            EditorGUILayout.BeginHorizontal();
            targetConditions.proximityEnabled = EditorGUILayout.ToggleLeft(new GUIContent("Proximity", "Define which IO is in collision with another. Uses the Proximity Collider Zone. Add Rig Group: Add this if you want to use the head or the hands of the user as the proximity zone."), targetConditions.proximityEnabled);
            EditorGUILayout.EndHorizontal();

            if (targetConditions.proximityEnabled)
            {
                // display the OnEnter OR OnExit condition for the list
                EditorGUILayout.BeginHorizontal();
                targetConditions.proximityMap.proximityStateIndex = EditorGUILayout.Popup(targetConditions.proximityMap.proximityStateIndex, Enum.GetNames(typeof(ProximityEventsAndStates)));

                if (hierarchyProximities.Count < 2)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.HelpBox("No other Interactive Object found.", MessageType.Warning);
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    targetConditions.requireAllProximities = EditorGUILayout.ToggleLeft("Require all", targetConditions.requireAllProximities);

                    if (targetConditions.proximityMap.proximityEntryList.Count > 0)
                    {
                        // NOTE don't use foreach to avoid InvalidOperationException
                        for (int i = 0; i < targetConditions.proximityMap.proximityEntryList.Count; i++)
                        {
                            // delete from the list the gazables no more in the hierarchy
                            if (!hierarchyProximities.Contains(targetConditions.proximityMap.proximityEntryList[i].dependentGameObject))
                            {
                                targetConditions.proximityMap.DeleteProximityEntry(targetConditions.proximityMap.proximityEntryList[i]);
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    // update the list of all possible rig groups
                    targetConditions.UpdateRigSets(Gaze_Proximity.HierarchyRigProximities);

                    if (targetConditions.proximityMap.proximityEntryGroupList.Count < 1 && Gaze_Proximity.HierarchyRigProximities.Count > 1)
                    {
                        // display 'add rig group' button
                        if (GUILayout.Button("Add Rig Group"))
                        {
                            targetConditions.proximityMap.AddProximityEntryGroup(targetConditions);
                        }
                    }

                    // This is a HOTFIX for solving editor problems that appear when user deletes every element of rig except one and there is a proximity rig group set up somewhere
                    // will need to be changed if custom proximity groups (other than rig group) are implemented
                    if (Gaze_Proximity.HierarchyRigProximities.Count < 2)
                    {
                        if (targetConditions.proximityMap.proximityEntryGroupList.Count > 0)
                        {
                            targetConditions.proximityMap.proximityEntryGroupList.Clear();
                        }
                    }
                    else
                    {
                        for (int i = 0; i < targetConditions.proximityMap.proximityEntryGroupList.Count; i++)
                        {
                            EditorGUILayout.BeginHorizontal();

                            // Display the popup with all possible combinations
                            targetConditions.proximityGroupIndex = EditorGUILayout.Popup(targetConditions.proximityGroupIndex, targetConditions.rigCombinations.ToArray());

                            targetConditions.proximityMap.proximityEntryGroupList[i].proximityEntries.Clear();
                            for (int j = 0; j < targetConditions.proximityRigGroups[targetConditions.proximityGroupIndex].Count; j++)
                            {
                                targetConditions.proximityMap.proximityEntryGroupList[i].AddProximityEntryToGroup(targetConditions.proximityRigGroups[targetConditions.proximityGroupIndex][j]);
                            }

                            if (GUILayout.Button("-"))
                            {
                                targetConditions.proximityMap.DeleteProximityEntryGroup(targetConditions.proximityMap.proximityEntryGroupList[i]);
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }

                    for (int i = 0; i < targetConditions.proximityMap.proximityEntryList.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal();

                        // Set the default collider for the gaze
                        if (targetConditions.proximityMap.proximityEntryList[i].dependentGameObject == null)
                        {
                            targetConditions.proximityMap.proximityEntryList[i].dependentGameObject = targetConditions.GetComponentInParent <Gaze_InteractiveObject>();
                        }

                        var proximityObject = EditorGUILayout.ObjectField(targetConditions.proximityMap.proximityEntryList[i].dependentGameObject, typeof(Gaze_InteractiveObject), true);

                        if (proximityObject != null)
                        {
                            targetConditions.proximityMap.proximityEntryList[i].dependentGameObject = (Gaze_InteractiveObject)proximityObject;
                        }

                        if (GUILayout.Button("-"))
                        {
                            targetConditions.proximityMap.DeleteProximityEntry(targetConditions.proximityMap.proximityEntryList[i]);
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    if (targetConditions.proximityMap.proximityEntryList.Count + targetConditions.proximityMap.proximityEntryGroupList.Count < 2)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.HelpBox("You need at least two proximities.", MessageType.Warning);
                        EditorGUILayout.EndHorizontal();
                    }

                    // display 'add' button
                    if (GUILayout.Button("+"))
                    {
                        Gaze_ProximityEntry d = targetConditions.proximityMap.AddProximityEntry(targetConditions);
                        EditorGUILayout.BeginHorizontal();

                        // assign the first interactive object in the hierarchy list by default (0)
                        if (hierarchyProximities != null && hierarchyProximities.Count > 0)
                        {
                            if (d.dependentGameObject == null)
                            {
                                d.dependentGameObject = targetConditions.GetComponentInParent <Gaze_InteractiveObject>();
                            }

                            var proximityObject = EditorGUILayout.ObjectField(d.dependentGameObject, typeof(Gaze_InteractiveObject), true);

                            if (proximityObject != null)
                            {
                                d.dependentGameObject = (Gaze_InteractiveObject)proximityObject;
                            }

                            if (GUILayout.Button("-"))
                            {
                                targetConditions.proximityMap.DeleteProximityEntry(d);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.Space();
        }