Ejemplo n.º 1
0
        public bool Sync()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                // If we're in play mode then don't try and keep the overlay in sync
                // This also means we delete the overlay when entering playmode which stops unity getting confused about objects that shouldn't really exist
                InternalDestroy();
                return(false);
            }

            HullPainter selectedHullPainter = SelectionUtil.FindSelectedHullPainter();
            MeshFilter  selectedMeshFilter  = SelectionUtil.FindSelectedMeshFilter();

            if (selectedHullPainter != null)
            {
                SyncParentChain(selectedHullPainter.gameObject);

                FindOrCreateOverlay();

                FindOrCreatePickClone();

                SyncPickClone(selectedMeshFilter);

                SyncOverlay(selectedHullPainter);
            }
            else
            {
                if (pickClone != null)
                {
                    targetMeshCollider.enabled = false;
                }

                if (overlayObject != null)
                {
                    overlayRenderer.enabled = false;
                }
            }

            bool changed = false;

            if (currentHullPainter != selectedHullPainter)
            {
                currentHullPainter = selectedHullPainter;
                changed            = true;
            }

            return(changed);
        }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            if (technieIcon == null)
            {
                string installPath = HullPainterWindow.FindInstallPath();
                technieIcon = AssetDatabase.LoadAssetAtPath <Texture>(installPath + "TechnieIcon.png");
            }

            if (HullPainterWindow.IsOpen())
            {
                HullPainterWindow window = HullPainterWindow.instance;

                window.OnInspectorGUI();
            }

            HullPainter selectedPainter = SelectionUtil.FindSelectedHullPainter();

            if (selectedPainter != null)
            {
                if (selectedPainter.paintingData != null &&
                    selectedPainter.hullData != null)
                {
                    if (GUILayout.Button(new GUIContent("Open Hull Painter", technieIcon)))
                    {
                        EditorWindow.GetWindow(typeof(HullPainterWindow));
                    }
                }
                else
                {
                    MeshFilter srcMeshFilter = selectedPainter.gameObject.GetComponent <MeshFilter>();
                    Mesh       srcMesh       = srcMeshFilter != null ? srcMeshFilter.sharedMesh : null;
                    if (srcMesh != null)
                    {
                        CommonUi.DrawGenerateOrReconnectGui(selectedPainter.gameObject, srcMesh);
                    }
                    else
                    {
                        GUILayout.Label("No mesh on current object!");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public bool Sync()
        {
            HullPainter selectedHullPainter = SelectionUtil.FindSelectedHullPainter();
            MeshFilter  selectedMeshFilter  = SelectionUtil.FindSelectedMeshFilter();

            if (selectedHullPainter != null)
            {
                SyncParentChain(selectedHullPainter.gameObject);

                FindOrCreateOverlay();

                FindOrCreatePickClone();

                SyncPickClone(selectedMeshFilter);

                SyncOverlay(selectedHullPainter);
            }
            else
            {
                if (pickClone != null)
                {
                    targetMeshCollider.enabled = false;
                }

                if (overlayObject != null)
                {
                    overlayRenderer.enabled = false;
                }
            }

            bool changed = false;

            if (currentHullPainter != selectedHullPainter)
            {
                currentHullPainter = selectedHullPainter;
                changed            = true;
            }

            return(changed);
        }
        public override void OnInspectorGUI()
        {
            if (HullPainterWindow.IsOpen())
            {
                HullPainterWindow window = HullPainterWindow.instance;

                window.OnInspectorGUI();
            }

            HullPainter selectedPainter = SelectionUtil.FindSelectedHullPainter();

            if (selectedPainter != null)
            {
                if (selectedPainter.paintingData != null &&
                    selectedPainter.hullData != null)
                {
                    if (GUILayout.Button("Open Hull Painter"))
                    {
                        EditorWindow.GetWindow(typeof(HullPainterWindow));
                    }
                }
                else
                {
                    MeshFilter srcMeshFilter = selectedPainter.gameObject.GetComponent <MeshFilter>();
                    Mesh       srcMesh       = srcMeshFilter != null ? srcMeshFilter.sharedMesh : null;
                    if (srcMesh != null)
                    {
                        CommonUi.DrawGenerateOrReconnectGui(selectedPainter.gameObject, srcMesh);
                    }
                    else
                    {
                        GUILayout.Label("No mesh on current object!");
                    }
                }
            }
        }