Exemple #1
0
    void OnManipulation(ManipulationEventData data)
    {
        if (FindObjectOfType <WarpzoneManager>().ActiveWarpzone != null)
        {
            var obj = PhotonNetwork.Instantiate(Path.Combine("OOI", "Spawnable", Object.name), transform.position, transform.rotation,
                                                (byte)TargetManager.Groups.PLAYERS);
            obj.transform.parent     = _virtualCity.transform;
            obj.transform.localScale = transform.lossyScale;

            var pointer     = data.Pointer as SpherePointer;
            var inputAction = pointer.PoseAction;
            var handedness  = pointer.Handedness;
            StartCoroutine(EndManipulation());
            IEnumerator EndManipulation()
            {
                yield return(null);

                _manipulator.ForceEndManipulation();
                _manipulator.enabled = false;
                _manipulator.GetComponent <Collider>().enabled = false;
                pointer.IsFocusLocked = false;
                yield return(null);

                _inputSystem.RaisePointerDown(pointer, inputAction, handedness);
                _manipulator.enabled = true;
                _manipulator.GetComponent <Collider>().enabled = true;
            }
        }
    }
Exemple #2
0
 public void SetObjectManipulator(ObjectManipulator objectManipulator)
 {
     this.objectManipulator = objectManipulator;
     Select();
     objectManipulator.IsAllowedChanged += onObjectManipulatorIsAllowedChanged;
     objectManipulator.GetComponent <ManipulatableObject>().IsSquashedChanged += onObjectManipulatorIsSquashedChanged;
 }
 public void AfterObjectDeselected(ObjectManipulator obj)
 {
     if (obj.GetComponent <ManipulatableStructure>() != null)
     {
         removeAttractorEvents();
     }
 }
        private void onObjectedDeselected(ObjectManipulator obj)
        {
            ManipulatableObject        component  = obj.GetComponent <ManipulatableObject>();
            ManipulatableObjectEffects component2 = obj.gameObject.GetComponent <ManipulatableObjectEffects>();
            Rigidbody component3 = obj.gameObject.GetComponent <Rigidbody>();

            if (!obj.WasReparented)
            {
                DecorationLayoutData decorationLayoutData = default(DecorationLayoutData);
                decorationLayoutData.Id           = DecorationLayoutData.ID.FromFullPath(GetRelativeGameObjectPath(obj.gameObject));
                decorationLayoutData.DefinitionId = component.DefinitionId;
                decorationLayoutData.Type         = component.Type;
                decorationLayoutData.Position     = obj.transform.localPosition;
                decorationLayoutData.Rotation     = obj.transform.localRotation;
                decorationLayoutData.UniformScale = obj.transform.localScale.x;
                DecorationLayoutData data = decorationLayoutData;
                SetCustomPropertiesInDecoration(ref data, obj.GetComponent <PartneredObject>());
                if (selectedObjectStartingId == null)
                {
                    SceneLayoutData.AddDecoration(data);
                }
                else
                {
                    string relativeGameObjectPath = GetRelativeGameObjectPath(component.gameObject);
                    SceneLayoutData.UpdateDecoration(relativeGameObjectPath, data);
                }
            }
            selectedObjectStartingId = null;
            if ((bool)component2)
            {
                component2.ClearObjectManipulator();
            }
            if ((bool)obj)
            {
                UnityEngine.Object.Destroy(obj);
            }
            if ((bool)component3)
            {
                UnityEngine.Object.Destroy(component3);
            }
            component.GetComponent <CollidableObject>().EnableTriggers(isTrigger: false);
            for (int i = 0; i < sceneModifiers.Length; i++)
            {
                sceneModifiers[i].AfterObjectDeselected(obj);
            }
            this.ObjectDeselected.InvokeSafe(component);
        }
Exemple #5
0
 public void ClearObjectManipulator()
 {
     if (objectManipulator != null)
     {
         Deselect();
         objectManipulator.IsAllowedChanged -= onObjectManipulatorIsAllowedChanged;
         objectManipulator.GetComponent <ManipulatableObject>().IsSquashedChanged -= onObjectManipulatorIsSquashedChanged;
         objectManipulator = null;
     }
 }
        private void ShowParticlesOnSelectedObject()
        {
            ObjectManipulator currentObjectManipulator = objectManipulationInputController.CurrentObjectManipulator;

            if (currentObjectManipulator != null)
            {
                CollidableObject component = currentObjectManipulator.GetComponent <CollidableObject>();
                if (component != null)
                {
                    Bounds bounds = component.GetBounds();
                    SetExtents(bounds.extents);
                    base.transform.position = bounds.center - new Vector3(0f, bounds.extents.y, 0f);
                    base.transform.rotation = Quaternion.identity;
                    TriggerParticles();
                }
            }
        }
    internal override List <KeyValuePair <DecorationDefinition, int> > GetDefinitionsToDisplay()
    {
        List <KeyValuePair <DecorationDefinition, int> > list = new List <KeyValuePair <DecorationDefinition, int> >();

        if (sceneLayoutData != null)
        {
            foreach (DecorationLayoutData item2 in sceneLayoutData.GetLayoutEnumerator())
            {
                DecorationLayoutData current = item2;
                if (current.Type == DecorationLayoutData.DefinitionType.Decoration && dictionaryOfDecorationDefinitions.ContainsKey(current.DefinitionId))
                {
                    DecorationDefinition decorationDefinition = dictionaryOfDecorationDefinitions[current.DefinitionId];
                    int availableDecorationCount = SceneRefs.Get <SceneManipulationService>().GetAvailableDecorationCount(decorationDefinition.Id);
                    KeyValuePair <DecorationDefinition, int> item = new KeyValuePair <DecorationDefinition, int>(decorationDefinition, availableDecorationCount);
                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
            }
        }
        if (SceneRefs.IsSet <SceneManipulationService>())
        {
            SceneManipulationService sceneManipulationService = SceneRefs.Get <SceneManipulationService>();
            if (sceneManipulationService.IsObjectSelectedForAdd)
            {
                ObjectManipulator currentObjectManipulator = sceneManipulationService.ObjectManipulationInputController.CurrentObjectManipulator;
                if (currentObjectManipulator != null)
                {
                    int definitionId = currentObjectManipulator.GetComponent <ManipulatableObject>().DefinitionId;
                    DecorationDefinition decorationDefinition = dictionaryOfDecorationDefinitions[definitionId];
                    int availableDecorationCount = sceneManipulationService.GetAvailableDecorationCount(decorationDefinition.Id);
                    KeyValuePair <DecorationDefinition, int> item = new KeyValuePair <DecorationDefinition, int>(decorationDefinition, availableDecorationCount);
                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
            }
        }
        return(list);
    }
        public override void OnInspectorGUI()
        {
            EditorGUILayout.PropertyField(hostTransform);
            EditorGUILayout.PropertyField(manipulationType);
            EditorGUILayout.PropertyField(allowFarManipulation);

            // Near Interaction Support foldout
            nearInteractionFoldout = EditorGUILayout.Foldout(nearInteractionFoldout, "Near Interaction Support", true);

            if (nearInteractionFoldout)
            {
                if (instance.GetComponent <NearInteractionGrabbable>() == null)
                {
                    EditorGUILayout.HelpBox($"By default, {nameof(ObjectManipulator)} only responds to far interaction input.  Add a {nameof(NearInteractionGrabbable)} component to enable near interaction support.", MessageType.Warning);

                    if (GUILayout.Button("Add Near Interaction Grabbable"))
                    {
                        instance.gameObject.AddComponent <NearInteractionGrabbable>();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox($"A {nameof(NearInteractionGrabbable)} is attached to this object, near interaction support is enabled.", MessageType.Info);
                }
            }

            var handedness = (ManipulationHandFlags)manipulationType.intValue;

            EditorGUILayout.Space();
            GUIStyle  style         = EditorStyles.foldout;
            FontStyle previousStyle = style.fontStyle;

            style.fontStyle  = FontStyle.Bold;
            oneHandedFoldout = EditorGUILayout.Foldout(oneHandedFoldout, "One Handed Manipulation", true);

            if (oneHandedFoldout)
            {
                if (handedness.IsMaskSet(ManipulationHandFlags.OneHanded))
                {
                    EditorGUILayout.PropertyField(oneHandRotationModeNear);
                    EditorGUILayout.PropertyField(oneHandRotationModeFar);
                }
                else
                {
                    EditorGUILayout.HelpBox("One handed manipulation disabled. If you wish to enable one handed manipulation select it as a Manipulation Type above.", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            twoHandedFoldout = EditorGUILayout.Foldout(twoHandedFoldout, "Two Handed Manipulation", true);

            if (twoHandedFoldout)
            {
                if (handedness.IsMaskSet(ManipulationHandFlags.TwoHanded))
                {
                    EditorGUILayout.PropertyField(twoHandedManipulationType);
                }
                else
                {
                    EditorGUILayout.HelpBox("Two handed manipulation disabled. If you wish to enable two handed manipulation select it as a Manipulation Type above.", MessageType.Info);
                }
            }

            var mh = (ObjectManipulator)target;
            var rb = mh.HostTransform.GetComponent <Rigidbody>();

            EditorGUILayout.Space();

            constraintsFoldout = ConstraintManagerInspector.DrawConstraintManagerFoldout(mh.gameObject,
                                                                                         enableConstraints,
                                                                                         constraintManager,
                                                                                         constraintsFoldout);

            EditorGUILayout.Space();
            physicsFoldout = EditorGUILayout.Foldout(physicsFoldout, "Physics", true);

            if (physicsFoldout)
            {
                if (rb != null)
                {
                    EditorGUILayout.PropertyField(releaseBehavior);
                    EditorGUILayout.PropertyField(useForcesForNearManipulation);
                }
                else
                {
                    EditorGUILayout.HelpBox("Physics options disabled. If you wish to enable physics options, add a Rigidbody component to this object.", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            smoothingFoldout = EditorGUILayout.Foldout(smoothingFoldout, "Smoothing", true);

            if (smoothingFoldout)
            {
                EditorGUILayout.PropertyField(transformSmoothingLogicType);
                EditorGUILayout.PropertyField(smoothingFar);
                EditorGUILayout.PropertyField(smoothingNear);
                EditorGUILayout.PropertyField(moveLerpTime);
                EditorGUILayout.PropertyField(rotateLerpTime);
                EditorGUILayout.PropertyField(scaleLerpTime);
            }

            EditorGUILayout.Space();
            eventsFoldout = EditorGUILayout.Foldout(eventsFoldout, "Manipulation Events", true);

            if (eventsFoldout)
            {
                EditorGUILayout.PropertyField(onManipulationStarted);
                EditorGUILayout.PropertyField(onManipulationEnded);
                EditorGUILayout.PropertyField(onHoverEntered);
                EditorGUILayout.PropertyField(onHoverExited);
            }

            EditorGUILayout.Space();

            Microsoft.MixedReality.Toolkit.Experimental.Editor.ElasticsManagerInspector.DrawElasticsManagerLink(elasticsManager, mh.gameObject);

            EditorGUILayout.Space();

            // reset foldouts style
            style.fontStyle = previousStyle;

            serializedObject.ApplyModifiedProperties();
        }