예제 #1
0
        protected virtual IEnumerator Start()
        {
            m_editor = IOC.Resolve <IRTE>();
            m_view   = GetComponent <MaterialPaletteView>();

            m_proBuilderTool = IOC.Resolve <IProBuilderTool>();
            m_paletteManager = IOC.Resolve <IMaterialPaletteManager>();
            m_paletteManager.PaletteChanged  += OnPaletteChanged;
            m_paletteManager.MaterialAdded   += OnMaterialAdded;
            m_paletteManager.MaterialCreated += OnMaterialCreated;
            m_paletteManager.MaterialRemoved += OnMaterialRemoved;

            yield return(new WaitUntil(() => m_paletteManager.IsReady));

            yield return(new WaitWhile(() => m_editor.IsBusy));

            m_view.TreeView.ItemDataBinding  += OnItemDataBinding;
            m_view.TreeView.ItemDrop         += OnItemDrop;
            m_view.TreeView.SelectionChanged += OnSelectionChanged;

            if (m_view.CreateMaterialButton != null)
            {
                m_view.CreateMaterialButton.onClick.AddListener(CreateMaterial);
            }

            m_view.TreeView.Items = m_paletteManager.Palette.Materials;

            m_view.TreeView.CanEdit        = false;
            m_view.TreeView.CanReorder     = true;
            m_view.TreeView.CanReparent    = false;
            m_view.TreeView.CanSelectAll   = false;
            m_view.TreeView.CanUnselectAll = true;
            m_view.TreeView.CanRemove      = false;
        }
예제 #2
0
        private void CreateNewShape(PBShapeType type, out GameObject go, out ExposeToEditor exposeToEditor)
        {
            go = PBShapeGenerator.CreateShape(type);
            go.AddComponent <PBMesh>();

            Renderer renderer = go.GetComponent <Renderer>();

            if (renderer != null && renderer.sharedMaterials.Length == 1 && renderer.sharedMaterials[0] == PBBuiltinMaterials.DefaultMaterial)
            {
                IMaterialPaletteManager paletteManager = IOC.Resolve <IMaterialPaletteManager>();
                if (paletteManager.Palette.Materials.Count > 0)
                {
                    renderer.sharedMaterial = paletteManager.Palette.Materials[0];
                }
            }

            IRuntimeEditor rte   = IOC.Resolve <IRuntimeEditor>();
            RuntimeWindow  scene = rte.GetWindow(RuntimeWindowType.Scene);
            Vector3        position;
            Quaternion     rotation;

            GetPositionAndRotation(scene, out position, out rotation);

            exposeToEditor        = go.AddComponent <ExposeToEditor>();
            go.transform.position = position + rotation * Vector3.up * exposeToEditor.Bounds.extents.y;
            go.transform.rotation = rotation;
        }
예제 #3
0
        private void OnWindowDestroyed(Transform obj)
        {
            if (obj == m_probuilderWindow)
            {
                m_probuilderWindow = null;
                m_proBuilderTool   = null;
                if (m_paletteManager != null)
                {
                    if (m_coPopulateTreeView != null)
                    {
                        StopCoroutine(m_coPopulateTreeView);
                        m_coPopulateTreeView = null;
                    }

                    m_paletteManager.PaletteChanged  -= OnPaletteChanged;
                    m_paletteManager.MaterialAdded   -= OnMaterialAdded;
                    m_paletteManager.MaterialCreated -= OnMaterialCreated;
                    m_paletteManager.MaterialRemoved -= OnMaterialRemoved;

                    if (m_view.CreateMaterialButton != null)
                    {
                        m_view.CreateMaterialButton.onClick.RemoveListener(CreateMaterial);
                    }

                    m_view.TreeView.Items = null;
                }
                m_paletteManager = null;
            }
        }
        protected virtual void Start()
        {
            if (transform.parent != null)
            {
                RuntimeWindow parent = transform.parent.GetComponentInParent <RuntimeWindow>();
                if (parent != null)
                {
                    Depth = parent.Depth + 1;
                }
            }

            //m_texturePreview.transform.position = new Vector3(ManualUVRenderer.Scale, ManualUVRenderer.Scale, 2) * 0.5f;
            m_texturePreview.transform.rotation              = Quaternion.Euler(90, 180, 0);
            m_texturePreview.transform.localScale            = Vector3.one * 10;
            m_texturePreview.sharedMaterial.mainTextureScale = Vector2.one * 10;
            m_graphicsLayer = IOCContainer.Resolve <IRTEGraphicsLayer>();
            m_graphicsLayer.Camera.RenderersCache.Add(m_texturePreview);

            m_materialEditor = IOC.Resolve <IMaterialEditor>();
            m_materialEditor.MaterialsApplied += OnMaterialApplied;

            m_paletteManager = IOC.Resolve <IMaterialPaletteManager>();
            m_paletteManager.PaletteChanged  += OnPaletteChanged;
            m_paletteManager.MaterialAdded   += OnMaterialsChanged;
            m_paletteManager.MaterialCreated += OnMaterialsChanged;
            m_paletteManager.MaterialRemoved += OnMaterialsChanged;
        }
예제 #5
0
        private void OnWindowCreated(Transform obj)
        {
            if (obj == m_wm.GetWindow("ProBuilder"))
            {
                m_probuilderWindow = obj;
                m_proBuilderTool   = IOC.Resolve <IProBuilderTool>();
                m_paletteManager   = IOC.Resolve <IMaterialPaletteManager>();
                m_paletteManager.PaletteChanged  += OnPaletteChanged;
                m_paletteManager.MaterialAdded   += OnMaterialAdded;
                m_paletteManager.MaterialCreated += OnMaterialCreated;
                m_paletteManager.MaterialRemoved += OnMaterialRemoved;

                m_coPopulateTreeView = CoPopulateTreeView();
                StartCoroutine(m_coPopulateTreeView);
            }
        }
예제 #6
0
        private static void CreateShape(PBShapeType type, out GameObject go, out ExposeToEditor exposeToEditor)
        {
            go = PBShapeGenerator.CreateShape(type);
            go.AddComponent <PBMesh>();

            Renderer renderer = go.GetComponent <Renderer>();

            if (renderer != null && renderer.sharedMaterials.Length == 1 && renderer.sharedMaterials[0] == PBBuiltinMaterials.DefaultMaterial)
            {
                IMaterialPaletteManager paletteManager = IOC.Resolve <IMaterialPaletteManager>();
                if (paletteManager.Palette.Materials.Count > 0)
                {
                    renderer.sharedMaterial = paletteManager.Palette.Materials[0];
                }
            }

            exposeToEditor = go.AddComponent <ExposeToEditor>();
        }
예제 #7
0
        private object OnNewShape(object arg)
        {
            GameObject go = PBShapeGenerator.CreateShape((PBShapeType)arg);

            go.AddComponent <PBMesh>();

            Renderer renderer = go.GetComponent <Renderer>();

            if (renderer != null && renderer.sharedMaterials.Length == 1 && renderer.sharedMaterials[0] == PBBuiltinMaterials.DefaultMaterial)
            {
                IMaterialPaletteManager paletteManager = IOC.Resolve <IMaterialPaletteManager>();
                if (paletteManager.Palette.Materials.Count > 0)
                {
                    renderer.sharedMaterial = paletteManager.Palette.Materials[0];
                }
            }

            IRuntimeEditor rte   = IOC.Resolve <IRuntimeEditor>();
            RuntimeWindow  scene = rte.GetWindow(RuntimeWindowType.Scene);
            Vector3        position;
            Quaternion     rotation;

            GetPositionAndRotation(scene, out position, out rotation);

            ExposeToEditor exposeToEditor = go.AddComponent <ExposeToEditor>();

            go.transform.position = position + rotation * Vector3.up * exposeToEditor.Bounds.extents.y;
            go.transform.rotation = rotation;

            Editor.Undo.BeginRecord();
            Editor.Selection.activeGameObject = go;
            Editor.Undo.RegisterCreatedObjects(new[] { exposeToEditor });
            Editor.Undo.EndRecord();

            return(go);
        }