Beispiel #1
0
        /** Gui drawn if the selected object does not have a valid and initialised hull painter on it
         */
        private void DrawInactiveGui()
        {
            if (Selection.transforms.Length == 1)
            {
                // Have a single scene selection, is it viable?

                GameObject       selectedObject = Selection.transforms[0].gameObject;
                MeshFilter       srcMesh        = SelectionUtil.FindSelectedMeshFilter();
                HullPainterChild child          = SelectionUtil.FindSelectedHullPainterChild();

                if (srcMesh != null)
                {
                    GUILayout.Space(10);
                    GUILayout.Label("Generate an asset to start painting:");
                    CommonUi.DrawGenerateOrReconnectGui(selectedObject, srcMesh.sharedMesh);
                }
                else if (child != null)
                {
                    GUILayout.Space(10);
                    GUILayout.Label("Child hulls are not edited directly - select the parent to continue painting this hull");
                }
                else
                {
                    // No mesh filter, might have a hull painter (or not)

                    GUILayout.Space(10);
                    GUILayout.Label("To start painting, select a single scene object");
                    GUILayout.Label("The object must contain a MeshFilter");

                    GUILayout.Space(10);
                    GUILayout.Label("No MeshFilter on selected object", EditorStyles.centeredGreyMiniLabel);
                }
            }
            else
            {
                // No single scene selection
                // Could be nothing selected
                // Could be multiple selection
                // Could be an asset in the project selected

                GUILayout.Space(10);
                GUILayout.Label("To start painting, select a single scene object");
                GUILayout.Label("The object must contain a MeshFilter");

                if (GUILayout.Button("Open quick start guide"))
                {
                    string projectPath = Application.dataPath.Replace("Assets", "");
                    string docsPdf     = projectPath + FindInstallPath() + "Technie Collider Creator Readme.pdf";
                    Application.OpenURL(docsPdf);
                }
            }
        }
Beispiel #2
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);
        }
Beispiel #3
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!");
                    }
                }
            }
        }
Beispiel #4
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);
        }
Beispiel #5
0
        /** Gui drawn if the selected object does not have a valid and initialised hull painter on it
         */
        private void DrawInactiveGui()
        {
            if (Selection.transforms.Length == 1)
            {
                // Have a single scene selection, is it viable?

                GameObject selectedObject = Selection.transforms[0].gameObject;
                MeshFilter srcMesh        = SelectionUtil.FindSelectedMeshFilter();

                if (srcMesh != null)
                {
                    GUILayout.Space(10);
                    GUILayout.Label("Generate an asset to start painting:");
                    CommonUi.DrawGenerateOrReconnectGui(selectedObject, srcMesh.sharedMesh);
                }
                else
                {
                    // No mesh filter, might have a hull painter (or not)

                    GUILayout.Space(10);
                    GUILayout.Label("To start painting, select a single scene object");
                    GUILayout.Label("The object must contain a MeshFilter");

                    GUILayout.Space(10);
                    GUILayout.Label("No MeshFilter on selected object", EditorStyles.centeredGreyMiniLabel);
                }
            }
            else
            {
                // No single scene selection
                // Could be nothing selected
                // Could be multiple selection
                // Could be an asset in the project selected

                GUILayout.Space(10);
                GUILayout.Label("To start painting, select a single scene object");
                GUILayout.Label("The object must contain a MeshFilter");
            }
        }
        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!");
                    }
                }
            }
        }