public bool DragControlPoint(bool extend)
        {
            PositionHandle positionHandle = m_editor.Tools.ActiveTool as PositionHandle;

            if (m_picker.IsControlPointSelected && positionHandle != null && positionHandle.IsDragging)
            {
                if (extend)
                {
                    ControlPointPicker picker       = m_editor.Selection.activeGameObject.GetComponent <ControlPointPicker>();
                    BaseSpline         spline       = picker.Selection.GetSpline();
                    BaseSplineState    oldState     = spline.GetState();
                    PickResult         oldSelection = picker.Selection != null ? new PickResult(picker.Selection) : null;
                    m_picker.Drag(true);
                    spline = picker.Selection.GetSpline();
                    BaseSplineState newState     = spline.GetState();
                    PickResult      newSelection = picker.Selection != null ? new PickResult(picker.Selection) : null;
                    RecordState(spline.gameObject, oldState, newState, picker, oldSelection, newSelection);
                }
                else
                {
                    m_picker.Drag(false);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public PositionHandle AddPositionHandle(Vector2 position)
        {
            PositionHandle ph = new PositionHandle();

            ph.position = position;
            positionHandles.Add(ph);
            return(ph);
        }
Exemplo n.º 3
0
    void OnSceneGUI()
    {
        m_Target = (PositionHandle)target;

        for (int i = 0; i < m_Target.transform.childCount; ++i)
        {
            Transform Child = m_Target.transform.GetChild(i);

            Child.position = Handles.PositionHandle(Child.position, Child.rotation);
        }
    }
Exemplo n.º 4
0
        private void Awake()
        {
            camera = Camera.main;

            m_Target = transform;

            m_PositionHandle = new PositionHandle(this);
            m_RotationHandle = new RotationHandle(this);
            m_ScaleHandle    = new ScaleHandle(this);
            m_CurrentHandle  = m_PositionHandle;
        }
Exemplo n.º 5
0
        private void OnDrawGizmos()
        {
            for (int kIndex = 0; kIndex < positionHandles.Count; kIndex++)
            {
                PositionHandle ph = positionHandles[kIndex];
                UnityEditor.Handles.DoPositionHandle(ph.position, Quaternion.identity);
            }

            for (int kIndex = 0; kIndex < labels.Count; kIndex++)
            {
                Label l = labels[kIndex];
                UnityEditor.Handles.Label(l.position, l.text);
            }
        }
Exemplo n.º 6
0
    void Start()
    {
        if (this.GetComponent <PositionHandle>() == null)
        {
            gameObject.AddComponent <PositionHandle>();
        }
        if (this.GetComponent <RotationHandle>() == null)
        {
            gameObject.AddComponent <RotationHandle>();
        }

        posHandle         = GetComponent <PositionHandle>();
        rotHandle         = GetComponent <RotationHandle>();
        posHandle.enabled = false;
        rotHandle.enabled = false;
    }
Exemplo n.º 7
0
        private void Awake()
        {
            if (Camera == null)
            {
                Camera = Camera.main;
            }

            if (Run.Instance == null)
            {
                GameObject runGO = new GameObject();
                runGO.name = "Run";
                runGO.AddComponent <Run>();
            }
            RuntimeTools.Current = RuntimeTool.View;
            GameObject positionHandle = new GameObject();

            positionHandle.name = "PositionHandle";
            positionHandle.transform.SetParent(transform, false);
            m_positionHandle = positionHandle.AddComponent <PositionHandle>();
            positionHandle.SetActive(false);

            GameObject rotationHandle = new GameObject();

            rotationHandle.name = "RotationHandle";
            rotationHandle.transform.SetParent(transform, false);
            m_rotationHandle = rotationHandle.AddComponent <RotationHandle>();
            rotationHandle.SetActive(false);

            GameObject scaleHandle = new GameObject();

            scaleHandle.name = "ScaleHandle";
            scaleHandle.transform.SetParent(transform, false);
            m_scaleHandle = scaleHandle.AddComponent <ScaleHandle>();
            scaleHandle.SetActive(false);

            RuntimeSelection.SelectionChanged    += OnRuntimeSelectionChanged;
            RuntimeTools.ToolChanged             += OnRuntimeToolChanged;
            RuntimeTools.CameraEulerChanged      += OnCameraEulerChanged;
            UnityEditorToolsListener.ToolChanged += OnUnityEditorToolChanged;
            RuntimeTools.Current = RuntimeTool.Move;

            Camera.fieldOfView = 60;
            OnProjectionChanged();
        }
Exemplo n.º 8
0
        private LayoutInfo DefaultLayout(IWindowManager wm)
        {
            bool isDialog;

            WindowDescriptor sceneWd;
            GameObject       sceneContent;

            wm.CreateWindow(RuntimeWindowType.Scene.ToString(), out sceneWd, out sceneContent, out isDialog);

            WindowDescriptor sceneXWd;
            GameObject       sceneXContent;
            RuntimeWindow    xWindow = wm.CreateWindow(RuntimeWindowType.Scene.ToString(), out sceneXWd, out sceneXContent, out isDialog).GetComponent <RuntimeWindow>();

            // xWindow.CanActivate = false;

            RunNextFrame(() =>
            {
                IScenePivot xPivot    = xWindow.IOCContainer.Resolve <IScenePivot>();
                xPivot.Pivot.position = new Vector3(5, 0, 0);

                xWindow.Camera.transform.position = Vector3.right * 20;
                xWindow.Camera.transform.LookAt(xPivot.Pivot);
                xWindow.Camera.orthographic = true;

                PositionHandle positionHandle = wm.GetComponents(xWindow.transform).SelectMany(c => c.GetComponentsInChildren <PositionHandle>(true)).FirstOrDefault();
                positionHandle.GridSize       = 2;

                RotationHandle rotationHandle = wm.GetComponents(xWindow.transform).SelectMany(c => c.GetComponentsInChildren <RotationHandle>(true)).FirstOrDefault();
                rotationHandle.GridSize       = 5;

                Tab tab = Region.FindTab(xWindow.transform);
                tab.IsCloseButtonVisible = false;
            });

            WindowDescriptor gameWd;
            GameObject       gameContent;

            wm.CreateWindow(RuntimeWindowType.Game.ToString(), out gameWd, out gameContent, out isDialog);

            WindowDescriptor inspectorWd;
            GameObject       inspectorContent;

            wm.CreateWindow(RuntimeWindowType.Inspector.ToString(), out inspectorWd, out inspectorContent, out isDialog);

            WindowDescriptor hierarchyWd;
            GameObject       hierarchyContent;

            wm.CreateWindow(RuntimeWindowType.Hierarchy.ToString(), out hierarchyWd, out hierarchyContent, out isDialog);

            LayoutInfo layout = new LayoutInfo(false,
                                               new LayoutInfo(true,
                                                              new LayoutInfo(
                                                                  new LayoutInfo(sceneContent.transform, sceneWd.Header, sceneWd.Icon),
                                                                  new LayoutInfo(gameContent.transform, gameWd.Header, gameWd.Icon)),
                                                              new LayoutInfo(sceneXContent.transform, sceneXWd.Header, sceneXWd.Icon),
                                                              0.5f),
                                               new LayoutInfo(true,
                                                              new LayoutInfo(inspectorContent.transform, inspectorWd.Header, inspectorWd.Icon),
                                                              new LayoutInfo(hierarchyContent.transform, hierarchyWd.Header, hierarchyWd.Icon),
                                                              0.5f),
                                               0.75f);

            return(layout);
        }