private void onObjectRemoved(GameObject obj, bool deleteChildren)
        {
            DecorationLayoutData decorationLayoutData = default(DecorationLayoutData);

            decorationLayoutData.Id = DecorationLayoutData.ID.FromFullPath(GetRelativeGameObjectPath(obj));
            DecorationLayoutData decoration = decorationLayoutData;

            SceneLayoutData.RemoveDecoration(decoration, deleteChildren);
            if (selectedObjectStartingId == decoration.Id.GetFullPath())
            {
                selectedObjectStartingId = null;
                ObjectManipulator component = obj.GetComponent <ObjectManipulator>();
                if (component != null)
                {
                    for (int i = 0; i < sceneModifiers.Length; i++)
                    {
                        sceneModifiers[i].AfterObjectDeselected(component);
                    }
                }
            }
            decorationInventoryService.MarkStructuresDirty();
            decorationInventoryService.MarkDecorationsDirty();
            if (this.ObjectRemoved != null)
            {
                ManipulatableObject component2 = obj.GetComponent <ManipulatableObject>();
                this.ObjectRemoved.InvokeSafe(component2);
            }
            UnityEngine.Object.Destroy(obj);
            removePartneredObject(obj);
        }
 public void AfterObjectDeselected(ObjectManipulator obj)
 {
     if (obj.GetComponent <ManipulatableStructure>() != null)
     {
         removeAttractorEvents();
     }
 }
        private void InitializeControls()
        {
            if (!(objectManipulationInputController.CurrentlySelectedObject != null))
            {
                return;
            }
            ManipulatableObject componentInParent  = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>();
            ObjectManipulator   componentInParent2 = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>();

            if (!(componentInParent2 != null))
            {
                return;
            }
            switch (componentInParent.Type)
            {
            case DecorationLayoutData.DefinitionType.Structure:
                HideRotationControls();
                HideScaleControls();
                break;

            case DecorationLayoutData.DefinitionType.Decoration:
            {
                IGameData gameData = Service.Get <IGameData>();
                Dictionary <int, DecorationDefinition> dictionary = gameData.Get <Dictionary <int, DecorationDefinition> >();
                if (dictionary.ContainsKey(componentInParent.DefinitionId))
                {
                    DecorationDefinition def = dictionary[componentInParent.DefinitionId];
                    ConfigureScalingOptions(def, componentInParent2);
                    ConfigureRotationOptions(def, componentInParent2);
                }
                break;
            }
            }
        }
        private void onObjectSelected(ManipulatableObject obj)
        {
            if (obj == null)
            {
                return;
            }
            for (int i = 0; i < sceneModifiers.Length; i++)
            {
                if (!sceneModifiers[i].CanObjectBeSelected(obj))
                {
                    return;
                }
            }
            ObjectManipulator objectManipulator = obj.gameObject.AddComponentIfMissing <ObjectManipulator>();

            objectManipulationManager.WatchObject(objectManipulator);
            obj.GetComponent <CollidableObject>().EnableTriggers();
            obj.GetComponent <ManipulatableObjectEffects>().SetObjectManipulator(objectManipulator);
            Rigidbody rigidbody = obj.gameObject.AddComponentIfMissing <Rigidbody>();

            rigidbody.isKinematic = true;
            rigidbody.useGravity  = false;
            for (int i = 0; i < sceneModifiers.Length; i++)
            {
                sceneModifiers[i].AfterObjectSelected(obj, isNewObject);
            }
            isNewObject = false;
            selectedObjectStartingId = GetRelativeGameObjectPath(obj.gameObject);
            ManipulatableObject[] componentsInChildren = obj.GetComponentsInChildren <ManipulatableObject>();
            foreach (ManipulatableObject manipulatableObject in componentsInChildren)
            {
                manipulatableObject.PathId = GetRelativeGameObjectPath(manipulatableObject.gameObject);
            }
        }
Exemplo n.º 5
0
        private bool ResetSelected(bool objectBeingDeleted, bool deleteChildren)
        {
            bool flag = false;

            if (CurrentlySelectedObject != null)
            {
                ManipulatableObject component         = CurrentlySelectedObject.GetComponent <ManipulatableObject>();
                ObjectManipulator   componentInParent = CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>();
                if (componentInParent != null)
                {
                    if (componentInParent.IsAllowed)
                    {
                        Transform parent = CurrentlySelectedObject.transform.parent;
                        CurrentlySelectedObject.transform.SetParent(oldParentOfSelectedObject, worldPositionStays: true);
                        component.SetParent(parent);
                        componentInParent.WasReparented = true;
                    }
                    else if (!restoreOldObject())
                    {
                        flag = true;
                    }
                    if (!objectBeingDeleted && this.ObjectDeselected != null)
                    {
                        this.ObjectDeselected.InvokeSafe(componentInParent);
                    }
                    if (flag)
                    {
                        component.RemoveObject(deleteChildren);
                    }
                }
            }
            CurrentlySelectedObject = null;
            return(flag);
        }
 private void onAttracted(MultiPointLineAttractor attractor, Collider collider, ObjectManipulator other, Quaternion rotation)
 {
     other.BaseLocationIsValid = true;
     other.SetPosition(collider.transform.position);
     other.SetRotation(rotation);
     attractor.OnUnSnapped += onUnSnap;
 }
Exemplo n.º 7
0
        public void Post(string classCode, [FromBody] JObject obj)
        {
            Class             @class            = this.GetValidatedClass(classCode);
            ObjectManipulator objectManipulator = new ObjectManipulator(this);

            objectManipulator.BeginCreateTransaction(classCode);

            foreach (JProperty property in obj.Properties())
            {
                try
                {
                    objectManipulator.SetPropertyValue(property.Name, property.Value);
                }

                catch (System.ArgumentException e)
                {
                    throw new HttpException(400, e.Message);
                }
            }

            int    objectId = objectManipulator.CommitTransaction();
            Object @object  = this.Storage.GetRepository <IObjectRepository>().WithKey(objectId);

            Event <IObjectCreatedEventHandler, IRequestHandler, Object> .Broadcast(this, @object);
        }
Exemplo n.º 8
0
 public void SetObjectManipulator(ObjectManipulator objectManipulator)
 {
     this.objectManipulator = objectManipulator;
     Select();
     objectManipulator.IsAllowedChanged += onObjectManipulatorIsAllowedChanged;
     objectManipulator.GetComponent <ManipulatableObject>().IsSquashedChanged += onObjectManipulatorIsSquashedChanged;
 }
 void Start()
 {
     PV = GameObject.FindGameObjectWithTag("WorldEvent").GetComponent <PhotonView>();
     experimentManager = GameObject.FindGameObjectWithTag("ExperimentManager").GetComponent <ExperimentManager_Old>();
     objectManipulator = gameObject.GetComponent <ObjectManipulator>();
     objectManipulator.OnManipulationStarted.AddListener(OnGesture);
 }
Exemplo n.º 10
0
    private void Awake()
    {
        _inputSystem = FindObjectOfType <MixedRealityToolkit>().GetService <MixedRealityInputSystem>();
        _virtualCity = FindObjectOfType <VirtualCity>();

        var ooi = GetComponent <OOI>();

        if (ooi)
        {
            Destroy(ooi);
        }
        Destroy(GetComponent <AugmentixTransformView>());
        Destroy(GetComponent <PhotonView>());

        _manipulator = gameObject.AddComponent <ObjectManipulator>();
        _manipulator.ReleaseBehavior = 0;
        gameObject.AddComponent <NearInteractionGrabbable>();
        gameObject.AddComponent <MinMaxScaleConstraint>();
        _manipulator.OnManipulationStarted.AddListener(OnManipulation);
        _manipulator.OnManipulationEnded.AddListener(data =>
        {
            GetComponent <Rigidbody>().velocity        = Vector3.zero;
            GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
        });
    }
Exemplo n.º 11
0
 private void OnObjectManipulatorObjectDeselected(ObjectManipulator objectManipulator)
 {
     if (objectManipulator.IsAllowed)
     {
         SplitChildren();
     }
 }
Exemplo n.º 12
0
        private void OnActiveSelectionStateTouchPhaseMoved(GameObject obj, Vector2 touchPosition)
        {
            CurrentState.ExitState();
            ObjectManipulator objectManipulator = null;

            if (obj != null)
            {
                objectManipulator = obj.GetComponentInParent <ObjectManipulator>();
                if (NaturalDragFromTouchPosition)
                {
                    Vector2 vector = Camera.main.WorldToScreenPoint(obj.transform.position);
                    touchOffset = vector - touchPosition;
                }
            }
            if (objectManipulator == null)
            {
                CurrentState = swipeScreenInputState;
            }
            else
            {
                dragItemInputInteractionState.CurrentlySelectedObject = obj;
                dragItemInputInteractionState.TouchOffset             = touchOffset;
                CurrentState = dragItemInputInteractionState;
            }
            CurrentState.EnterState(TargetLayerMask, MinTimeToMoveInput);
        }
    private void OnSelectedObjectManipulatorTriggerEnter(Collider otherCollider)
    {
        ObjectManipulator currentObjectManipulator = objectManipulationInputController.CurrentObjectManipulator;
        CollidableObject  componentInParent        = otherCollider.gameObject.GetComponentInParent <CollidableObject>();

        if (componentInParent != null && currentObjectManipulator != null)
        {
            switch (objectManipulationInputController.GetCollisionRule(componentInParent))
            {
            case CollisionRuleResult.Stack:
            case CollisionRuleResult.StackXNormal:
                break;

            case CollisionRuleResult.Intersect:
                break;

            case CollisionRuleResult.NotAllowed:
                currentObjectManipulator.CollisionIsValid = false;
                break;

            case CollisionRuleResult.Squash:
                componentInParent.IsSquashed = true;
                break;
            }
        }
    }
Exemplo n.º 14
0
        public void TestCreatingAnObject()
        {
            //Setup
            dynamic dynamicCustomer = new ExpandoObject();

            var propertyName1  = "CustomerName";
            var propertyValue1 = "BehrangBina";
            var propertyName2  = "CustomerEmail";
            var propertyValue2 = "*****@*****.**";
            var propertyName3  = "CustomerAge";
            var propertyValue3 = 39;

            ObjectManipulator.AddProperty(dynamicCustomer, propertyName1, propertyValue1);
            ObjectManipulator.AddProperty(dynamicCustomer, propertyName2, propertyValue2);
            ObjectManipulator.AddProperty(dynamicCustomer, propertyName3, propertyValue3);

            var firstPropertyName  = ObjectManipulator.GetExpandoObjectPropertyName(dynamicCustomer, 1);
            var firstPropertyValue = ObjectManipulator.GetExpandoObjectPropertyValue(dynamicCustomer, 1);

            Assert.True(firstPropertyName.Equals(propertyName1), "First Property Name Should be: " + propertyName1);
            Assert.True(firstPropertyValue.Equals(propertyValue1), "First Property Value Should be: " + propertyValue1);

            var secondPropertyName  = ObjectManipulator.GetExpandoObjectPropertyName(dynamicCustomer, 2);
            var secondPropertyValue = ObjectManipulator.GetExpandoObjectPropertyValue(dynamicCustomer, 2);

            Assert.True(secondPropertyName.Equals(propertyName2), "Second Property Name Should be: " + propertyName2);
            Assert.True(secondPropertyValue.Equals(propertyValue2), "Second Property Value Should be: " + propertyValue2);

            var thirdPropertyName  = ObjectManipulator.GetExpandoObjectPropertyName(dynamicCustomer, 3);
            var thirdPropertyValue = ObjectManipulator.GetExpandoObjectPropertyValue(dynamicCustomer, 3);

            Assert.True(thirdPropertyName.Equals(propertyName3), "Third Property Name Should be: " + propertyName3);
            Assert.True(thirdPropertyValue.Equals(propertyValue3), "Third Property Value Should be: " + propertyValue3);
        }
Exemplo n.º 15
0
    void Awake()
    {
        objectManipulator        = GetComponent <ObjectManipulator>();
        objectManipulatorDynamic = GetComponent <ObjectManipulatorDynamicHover>();
        audioSource = GetComponent <AudioSource>();

        //objectManipulator.OnHoverEntered.AddListener(HoverDistance);
    }
 private void OnObjectManipulatorChanged(ObjectManipulator objectManipulator)
 {
     ManipulatableObject[] componentsInChildren = objectManipulator.GetComponentsInChildren <ManipulatableObject>();
     foreach (ManipulatableObject manipulatableObject in componentsInChildren)
     {
         UpdateLayoutForManipulatableObject(manipulatableObject.transform.parent, manipulatableObject);
     }
 }
 public void WatchObject(ObjectManipulator m)
 {
     if (m != null)
     {
         m.TriggerEnter += OnSelectedObjectManipulatorTriggerEnter;
         m.TriggerExit  += OnSelectedObjectManipulatorTriggerExit;
     }
 }
Exemplo n.º 18
0
    void Start()
    {
        modelManipulator = GetComponent <ModelManipulator>();

        container = GetComponent <ObjectManipulator>();
        model     = transform.Find("ModelContainer").GetComponent <ObjectManipulator>();

        model.scale(reducedScale);
    }
Exemplo n.º 19
0
 private void setPositionAtPointOnTopHit(RaycastHit topHit, ObjectManipulator selectedManipulator)
 {
     selectedManipulator.SetParent(Container);
     selectedManipulator.SetPosition(topHit.point);
     if (topHit.transform.gameObject.layer == LayerMask.NameToLayer("TerrainBarrier"))
     {
         selectedManipulator.AlignWith(topHit.normal, topHit.transform);
     }
 }
Exemplo n.º 20
0
 private void OnDragItemInputInteractionStateTouchPhaseStationary(RaycastHit topHit, TouchEquivalent touch)
 {
     PositionDragItem(topHit, touch);
     if (this.DragStateStationary != null)
     {
         ObjectManipulator componentInParent = CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>();
         this.DragStateStationary(componentInParent.gameObject, touch);
     }
 }
    private void onConfirmSquashedObjectBeforeDragComplete(ObjectManipulator selected, Action <bool> callback)
    {
        if (selected == null)
        {
            return;
        }
        HashSet <ManipulatableObject> squashed = new HashSet <ManipulatableObject>();

        foreach (Collider currentCollider in selected.CurrentColliders)
        {
            ManipulatableObject componentInParent = currentCollider.GetComponentInParent <ManipulatableObject>();
            if (componentInParent != null && componentInParent.IsSquashed)
            {
                squashed.Add(componentInParent);
                ManipulatableObject[] componentsInChildren = componentInParent.GetComponentsInChildren <ManipulatableObject>();
                for (int i = 0; i < componentsInChildren.Length; i++)
                {
                    squashed.Add(componentsInChildren[i]);
                }
            }
        }
        Action <int, Action <bool> > confirmObjectRemoval = Service.Get <ObjectManipulationService>().ConfirmObjectRemoval;

        if (squashed.Count > 0 && confirmObjectRemoval != null)
        {
            confirmObjectRemoval(squashed.Count, delegate(bool delete)
            {
                if (delete)
                {
                    foreach (ManipulatableObject item in squashed)
                    {
                        if (item != null)
                        {
                            item.RemoveObject(deleteChildren: false);
                        }
                    }
                }
                objectManipulationInputController.SkipOneFrame = true;
                if (callback != null)
                {
                    callback(delete);
                }
            });
            return;
        }
        foreach (ManipulatableObject item2 in squashed)
        {
            if (item2 != null)
            {
                item2.RemoveObject(deleteChildren: false);
            }
        }
        if (callback != null)
        {
            callback(obj: true);
        }
    }
Exemplo n.º 22
0
        /// <summary>
        /// Called if the user starts a gesture on the object
        /// Creates a copy based on the given prefab and initializes the copy
        /// </summary>
        /// <param name="eventData">The event data of the gesture</param>
        public void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            GameObject currentPointerTarget = eventData.Pointer.Result.CurrentPointerTarget;

            // only do this if we are out of selection mode, otherwise this is in conflict with the selection gesture
            if (!IssueSelectionManager.Instance.SelectionModeActive
                //clicking the edit or delete button shouldn't spawn a card
                && currentPointerTarget.GetComponent <EditButton>() == null && currentPointerTarget.GetComponent <DeleteButton>() == null)
            {
                // pass instantiation data to the copy so that other clients also know which issue is contained in the created copy
                object[] instantiationData;
                if (localDataDisplay.Content.Source == DataSource.REQUIREMENTS_BAZAAR)
                {
                    instantiationData = new object[1];
                }
                else if (localDataDisplay.Content.Source == DataSource.GITHUB)
                {
                    instantiationData    = new object[2];
                    instantiationData[1] = localDataDisplay.Content.ProjectId;
                }
                else
                {
                    Debug.LogError("Unexpected source: " + localDataDisplay.Content.Source, gameObject);
                    return;
                }

                instantiationData[0] = localDataDisplay.Content.Id; // same for ReqBaz and GitHub

                // create the copy, get the relevant components and set them up
                ResourceManager.Instance.SceneNetworkInstantiate(copyObject, transform.position, transform.rotation,
                                                                 (obj) =>
                {
                    copyInstance  = obj;
                    handlerOnCopy = copyInstance?.GetComponentInChildren <ObjectManipulator>();
                    IssueDataDisplay remoteDataDisplay = copyInstance?.GetComponent <IssueDataDisplay>();
                    if (handlerOnCopy == null || remoteDataDisplay == null)
                    {
                        if (handlerOnCopy == null)
                        {
                            SpecialDebugMessages.LogComponentNotFoundError(this, nameof(ObjectManipulator), copyInstance);
                        }
                        if (remoteDataDisplay == null)
                        {
                            SpecialDebugMessages.LogComponentNotFoundError(this, nameof(IssueDataDisplay), copyInstance);
                        }
                        PhotonNetwork.Destroy(copyInstance);
                    }
                    else
                    {
                        remoteDataDisplay.Setup(localDataDisplay.Content);
                        handlerOnCopy.OnPointerDown(eventData);
                    }
                },
                                                                 instantiationData);
            }
        }
Exemplo n.º 23
0
        private void Awake()
        {
            Debug.Assert(mrtkStandardMaterial);

            objectManipulator = gameObject.GetComponent <ObjectManipulator>();
            boundsControl     = gameObject.GetComponent <BoundsControl>();

            gltfAsset = gameObject.GetComponent <GltfAsset>();
            gltfAsset.onLoadComplete += OnLoadComplete;
        }
Exemplo n.º 24
0
 public void ClearObjectManipulator()
 {
     if (objectManipulator != null)
     {
         Deselect();
         objectManipulator.IsAllowedChanged -= onObjectManipulatorIsAllowedChanged;
         objectManipulator.GetComponent <ManipulatableObject>().IsSquashedChanged -= onObjectManipulatorIsSquashedChanged;
         objectManipulator = null;
     }
 }
Exemplo n.º 25
0
        void Start()
        {
            _objectManipulator = (ObjectManipulator)FindObjectOfType(typeof(ObjectManipulator));
            _objectManipulator.ObjectSpawned += this.OnObjectSpawned;

            dropdownAnimator = this.GetComponent <Animator>();
            itemList         = itemParent.GetComponent <VerticalLayoutGroup>();

            for (int i = 0; i < dropdownItems.Count; ++i)
            {
                GameObject go = Instantiate(itemObject, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                go.transform.SetParent(itemParent, false);

                setItemText      = go.GetComponentInChildren <TextMeshProUGUI>();
                textHelper       = dropdownItems[i].itemName;
                setItemText.text = textHelper;

                Transform goImage;
                goImage             = go.gameObject.transform.Find("Icon");
                setItemImage        = goImage.GetComponent <Image>();
                imageHelper         = dropdownItems[i].itemIcon;
                setItemImage.sprite = imageHelper;

                Button itemButton;
                itemButton = go.GetComponent <Button>();
                itemButton.onClick.AddListener(dropdownItems[i].OnItemSelection.Invoke);
                itemButton.onClick.AddListener(dropdownItems[i].OnPrefabSelection.Invoke);
                itemButton.onClick.AddListener(Animate);

                if (invokeAtStart == true)
                {
                    dropdownItems[i].OnItemSelection.Invoke();
                }
            }

            selectedText.text    = NameWhenUnselected;
            selectedImage.sprite = IconWhenUnselected;

            if (enableScrollbar == true)
            {
                itemList.padding.right = 25;
                scrollbar.SetActive(true);
            }

            else
            {
                itemList.padding.right = 8;
                Destroy(scrollbar);
            }

            if (enableIcon == false)
            {
                selectedImage.enabled = false;
            }
        }
Exemplo n.º 26
0
        private void Awake()
        {
            realtimeTransform   = GetComponent <RealtimeTransform>();
            objectManipulator   = GetComponent <ObjectManipulator>();
            manipulationHandler = GetComponent <ManipulationHandler>();
            rigidbody           = GetComponent <Rigidbody>();

            startPosition = transform.localPosition;
            startRotation = transform.localRotation;
            startScale    = transform.localScale;
        }
 public void SetNewDecoration(ManipulatableObject manipulatableObject)
 {
     removeDecorationListeners();
     this.manipulatableObject            = manipulatableObject;
     objectManipulator                   = manipulatableObject.GetComponent <ObjectManipulator>();
     objectManipulator.PositionChanged  += OnObjectManipulatorPositionChanged;
     objectManipulator.IsAllowedChanged += OnObjectManipulatorIsAllowedChanged;
     OnObjectManipulatorIsAllowedChanged();
     SetPosition();
     CoroutineRunner.Start(showNewDecoration(), this, "Show New Decoration");
 }
Exemplo n.º 28
0
 public void SetTrackedObject(ObjectManipulator obj, int size, ObjectManipulationInputController inputController)
 {
     trackedObject     = obj;
     trackedObjectSize = size;
     if (base.isActiveAndEnabled)
     {
         enabledAttractionPoints();
     }
     this.inputController = inputController;
     inputController.BeforeDragPosition += checkForSnapPosition;
 }
 private void onAfterManipulatableObjectReParented(Transform newParent, GameObject obj)
 {
     ObjectManipulator.SetUniqueGameObjectName(obj, newParent);
     UpdateLayoutForManipulatableObject(newParent, obj.GetComponent <ManipulatableObject>());
     foreach (Transform item in obj.transform)
     {
         ManipulatableObject component = item.GetComponent <ManipulatableObject>();
         if (component != null)
         {
             component.SetParent(component.transform.parent);
         }
     }
 }
Exemplo n.º 30
0
        public void Put(string classCode, int id, [FromBody] JObject @object)
        {
            ObjectManipulator objectManipulator = new ObjectManipulator(this);

            objectManipulator.BeginEditTransaction(classCode, id);

            foreach (JProperty property in @object.Properties())
            {
                objectManipulator.SetPropertyValue(property.Name, property.Value);
            }

            objectManipulator.CommitTransaction();
        }