コード例 #1
0
        public static ColliderPart Create(Transform parent, string name = "Collider")
        {
#if UNITY_EDITOR
            GameObject go = new GameObject(name);
            UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Created Collider Part GameObject");
            UnityEditor.Undo.SetTransformParent(go.transform, parent, "Parent New Collider Part GameObject");

            BuildRPart part = go.GetComponent <BuildRPart>();
            if (part == null)
            {
                part = UnityEditor.Undo.AddComponent <BuildRPart>(go);
            }

            part.parent = parent.GetComponent <BuildRPart>();

            ColliderPart output = UnityEditor.Undo.AddComponent <ColliderPart>(go);

            return(output);
#else
            GameObject go = new GameObject(name);
            go.transform.parent = parent;

            BuildRPart part = go.GetComponent <BuildRPart>();
            if (part == null)
            {
                part = go.AddComponent <BuildRPart>();
            }

            part.parent = parent.GetComponent <BuildRPart>();

            ColliderPart output = go.AddComponent <ColliderPart>();

            return(output);
#endif
        }
コード例 #2
0
        public void OnSceneGUI()
        {
            if (!_firstFrame)
            {
                return;
            }
            _firstFrame = false;

            Event evt = Event.current;

            if (evt != null && evt.alt)//do not modify selection
            {
                return;
            }

            if (target != null)
            {
                PART = (BuildRPart)target;
            }

            if (PART != null)
            {
                if (PART.parent != null)
                {
                    Selection.activeGameObject = PART.parent.gameObject;
                    return;
                }

                BUILDING = PART.transform.GetComponentInParent <Building>();

                if (BUILDING != null)
                {
                    Selection.activeGameObject = BUILDING.gameObject;

                    Volume volume = PART.GetComponent <Volume>();
                    if (volume != null && BuildingEditor.volume == null)
                    {
//                        BuildingEditor.MODE = BuildingEditor.EditModes.Volume;
                        BuildingEditor.volume = volume;
                        return;
                    }

                    Floorplan floorplan = PART.GetComponent <Floorplan>();
                    if (floorplan != null && BuildingEditor.floorplan == null)
                    {
                        BUILDING.settings.editMode = BuildREditmodes.Values.Floorplan;
                        volume = PART.transform.parent.GetComponent <Volume>();
                        BuildingEditor.volume    = volume;
                        BuildingEditor.floorplan = floorplan;
                        return;
                    }
                }
            }
        }
コード例 #3
0
ファイル: VisualPart.cs プロジェクト: ishui/unity3DScripts
        public static VisualPart Create(Transform parent, string name = "visual part")
        {
            HUtils.log();

#if UNITY_EDITOR
            GameObject go = new GameObject(name);
            UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Created Floorplan GameObject");
            UnityEditor.Undo.SetTransformParent(go.transform, parent, "Parent New Floorplan GameObject");
            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;

            BuildRPart part = go.GetComponent <BuildRPart>();
            if (part == null)
            {
                part = UnityEditor.Undo.AddComponent <BuildRPart>(go);
            }

            part.parent = parent.GetComponent <BuildRPart>();

            VisualPart output = UnityEditor.Undo.AddComponent <VisualPart>(go);

            return(output);
#else
            GameObject go = new GameObject(name);
            go.transform.parent = parent;

            BuildRPart part = go.GetComponent <BuildRPart>();
            if (part == null)
            {
                part = go.AddComponent <BuildRPart>();
            }

            part.parent = parent.GetComponent <BuildRPart>();

            VisualPart output = go.AddComponent <VisualPart>();

            return(output);
#endif
        }