コード例 #1
0
    void OnSceneGUI()
    {
        if (Event.current.type == EventType.MouseDown)
        {
            SplineDrawer drawer = target as SplineDrawer;
            Transform    t      = drawer.transform;
            if (Selection.activeTransform != t)
            {
                bool inChildren = false;
                foreach (Transform v in t)
                {
                    if (Selection.activeTransform == v)
                    {
                        inChildren = true;
                    }
                }
                if (!inChildren)
                {
                    return;
                }
            }

            Ray            ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
            GameObject     o   = new GameObject();
            SphereCollider sp  = o.AddComponent <SphereCollider>();
            sp.radius = 0.5f;
            RaycastHit hit;
            foreach (Transform v in t)
            {
                o.transform.position = v.position;
                if (sp.Raycast(ray, out hit, float.MaxValue))
                {
                    GUIUtility.hotControl     = 0;
                    Selection.activeTransform = v;
                }
            }
            DestroyImmediate(o);
        }
    }
コード例 #2
0
    protected override void OnScriptStart()
    {
        base.OnScriptStart();

        ToolName = "ZSSplineTool";
        _splineDrawer = SplineDrawer.GetInstance();
        _splineDrawer._splineParent = _splineParent;
        _splineDrawer.AddSpline();
        _splineDrawer.SetFirstKnotPrefab(firstKnotPrefab);
        _splineDrawer.SetKnotPrefab(knotPrefab);
        _splineDrawer.SetSplineMaterial(splineMaterials[_materialId]);
        _splineDrawer.SetSplineLayer(splineLayer);
        _splineDrawer.SetSplineRadius(splineRadius);
    }