Exemple #1
0
        private void Awake()
        {
            IOC.RegisterFallback <IProBuilderTool>(this);

            m_rte = IOC.Resolve <IRuntimeEditor>();

            m_wm = IOC.Resolve <IWindowManager>();
            m_wm.WindowCreated += OnWindowCreated;

            m_materialEditor = gameObject.AddComponent <PBMaterialEditor>();
            m_autoUVEditor   = gameObject.AddComponent <PBAutoUVEditor>();
            m_uv             = new PBAutoUnwrapSettings();
            m_uv.Changed    += OnUVChanged;

            PBVertexEditor vertexEditor = gameObject.AddComponent <PBVertexEditor>();
            PBEdgeEditor   edgeEditor   = gameObject.AddComponent <PBEdgeEditor>();
            PBFaceEditor   faceEditor   = gameObject.AddComponent <PBFaceEditor>();

            m_meshEditors = new IMeshEditor[4];
            m_meshEditors[(int)ProBuilderToolMode.Vertex] = vertexEditor;
            m_meshEditors[(int)ProBuilderToolMode.Edge]   = edgeEditor;
            m_meshEditors[(int)ProBuilderToolMode.Face]   = faceEditor;

            foreach (IMeshEditor editor in m_meshEditors)
            {
                if (editor == null)
                {
                    continue;
                }
                editor.CenterMode = m_rte.Tools.PivotMode == RuntimePivotMode.Center;
            }
            UpdateGlobalMode();

            m_pivot = new GameObject("Pivot").transform;
            LockAxes lockAxes = m_pivot.gameObject.AddComponent <LockAxes>();

            lockAxes.RotationFree = true;

            m_pivot.SetParent(transform, false);

            ExposeToEditor exposed = m_pivot.gameObject.AddComponent <ExposeToEditor>();

            exposed.CanDelete    = false;
            exposed.CanDuplicate = false;
            exposed.CanInspect   = false;
        }
        private void Awake()
        {
            IOC.RegisterFallback <IProBuilderTool>(this);

            m_rte = IOC.Resolve <IRuntimeEditor>();

            m_wm = IOC.Resolve <IWindowManager>();
            m_wm.WindowCreated += OnWindowCreated;
            foreach (RuntimeWindow window in m_rte.Windows)
            {
                if (window.WindowType == RuntimeWindowType.Scene)
                {
                    SetCullingMask(window);
                }
            }

            m_materialEditor  = gameObject.AddComponent <PBMaterialEditor>();
            m_autoUVEditor    = gameObject.AddComponent <PBAutoUVEditor>();
            m_polyShapeEditor = gameObject.AddComponent <ProBuilderPolyShapeEditor>();

            m_uv          = new PBAutoUnwrapSettings();
            m_uv.Changed += OnUVChanged;

            bool wasActive = gameObject.activeSelf;

            gameObject.SetActive(false);
            PBVertexEditor vertexEditor = gameObject.AddComponent <PBVertexEditor>();
            PBEdgeEditor   edgeEditor   = gameObject.AddComponent <PBEdgeEditor>();
            PBFaceEditor   faceEditor   = gameObject.AddComponent <PBFaceEditor>();

            m_meshEditors = new IMeshEditor[5];
            m_meshEditors[(int)ProBuilderToolMode.Vertex] = vertexEditor;
            m_meshEditors[(int)ProBuilderToolMode.Edge]   = edgeEditor;
            m_meshEditors[(int)ProBuilderToolMode.Face]   = faceEditor;

            foreach (IMeshEditor editor in m_meshEditors)
            {
                if (editor == null)
                {
                    continue;
                }
                editor.GraphicsLayer = m_rte.CameraLayerSettings.ExtraLayer1;
                editor.CenterMode    = m_rte.Tools.PivotMode == RuntimePivotMode.Center;
            }
            UpdateGlobalMode();

            m_pivot = new GameObject("Pivot").transform;
            LockAxes lockAxes = m_pivot.gameObject.AddComponent <LockAxes>();

            lockAxes.RotationFree = true;

            m_pivot.SetParent(transform, false);

            ExposeToEditor exposed = m_pivot.gameObject.AddComponent <ExposeToEditor>();

            exposed.CanDelete    = false;
            exposed.CanDuplicate = false;
            exposed.CanInspect   = false;

            gameObject.SetActive(wasActive);
        }